Azure IoT middleware for FreeRTOS
|
The JSON writer used by the middleware for PnP properties. More...
#include <stdbool.h>
#include <stdint.h>
#include "azure_iot_result.h"
#include "azure/core/az_json.h"
#include "azure/core/_az_cfg_prefix.h"
#include "azure/core/_az_cfg_suffix.h"
Go to the source code of this file.
Data Structures | |
struct | AzureIoTJSONWriter |
The struct to use for Azure IoT JSON writer functionality. More... | |
Typedefs | |
typedef struct AzureIoTJSONWriter | AzureIoTJSONWriter_t |
The struct to use for Azure IoT JSON writer functionality. | |
Functions | |
AzureIoTResult_t | AzureIoTJSONWriter_Init (AzureIoTJSONWriter_t *pxWriter, uint8_t *pucBuffer, uint32_t ulBufferSize) |
Initializes an AzureIoTJSONWriter_t which writes JSON text into a buffer passed. More... | |
AzureIoTResult_t | AzureIoTJSONWriter_AppendPropertyWithInt32Value (AzureIoTJSONWriter_t *pxWriter, const uint8_t *pucPropertyName, uint32_t ulPropertyNameLength, int32_t lValue) |
Appends the UTF-8 property name and value where value is int32. More... | |
AzureIoTResult_t | AzureIoTJSONWriter_AppendPropertyWithDoubleValue (AzureIoTJSONWriter_t *pxWriter, const uint8_t *pucPropertyName, uint32_t ulPropertyNameLength, double xValue, uint16_t usFractionalDigits) |
Appends the UTF-8 property name and value where value is double. More... | |
AzureIoTResult_t | AzureIoTJSONWriter_AppendPropertyWithBoolValue (AzureIoTJSONWriter_t *pxWriter, const uint8_t *pucPropertyName, uint32_t ulPropertyNameLength, bool usValue) |
Appends the UTF-8 property name and value where value is boolean. More... | |
AzureIoTResult_t | AzureIoTJSONWriter_AppendPropertyWithStringValue (AzureIoTJSONWriter_t *pxWriter, const uint8_t *pucPropertyName, uint32_t ulPropertyNameLength, const uint8_t *pucValue, uint32_t ulValueLen) |
Appends the UTF-8 property name and value where value is string. More... | |
int32_t | AzureIoTJSONWriter_GetBytesUsed (AzureIoTJSONWriter_t *pxWriter) |
Returns the length containing the JSON text written to the underlying buffer. More... | |
AzureIoTResult_t | AzureIoTJSONWriter_AppendString (AzureIoTJSONWriter_t *pxWriter, const uint8_t *pucValue, uint32_t ulValueLen) |
Appends the UTF-8 text value (as a JSON string) into the buffer. More... | |
AzureIoTResult_t | AzureIoTJSONWriter_AppendJSONText (AzureIoTJSONWriter_t *pxWriter, const uint8_t *pucJSON, uint32_t ulJSONLen) |
Appends an existing UTF-8 encoded JSON text into the buffer, useful for appending nested JSON. More... | |
AzureIoTResult_t | AzureIoTJSONWriter_AppendPropertyName (AzureIoTJSONWriter_t *pxWriter, const uint8_t *pusValue, uint32_t ulValueLen) |
Appends the UTF-8 property name (as a JSON string) which is the first part of a name/value pair of a JSON object. More... | |
AzureIoTResult_t | AzureIoTJSONWriter_AppendBool (AzureIoTJSONWriter_t *pxWriter, bool xValue) |
Appends a boolean value (as a JSON literal true or false ). More... | |
AzureIoTResult_t | AzureIoTJSONWriter_AppendInt32 (AzureIoTJSONWriter_t *pxWriter, int32_t lValue) |
Appends an int32_t number value. More... | |
AzureIoTResult_t | AzureIoTJSONWriter_AppendDouble (AzureIoTJSONWriter_t *pxWriter, double xValue, uint16_t usFractionalDigits) |
Appends a double number value. More... | |
AzureIoTResult_t | AzureIoTJSONWriter_AppendNull (AzureIoTJSONWriter_t *pxWriter) |
Appends the JSON literal null . More... | |
AzureIoTResult_t | AzureIoTJSONWriter_AppendBeginObject (AzureIoTJSONWriter_t *pxWriter) |
Appends the beginning of a JSON object (i.e. { ). More... | |
AzureIoTResult_t | AzureIoTJSONWriter_AppendBeginArray (AzureIoTJSONWriter_t *pxWriter) |
Appends the beginning of a JSON array (i.e. [ ). More... | |
AzureIoTResult_t | AzureIoTJSONWriter_AppendEndObject (AzureIoTJSONWriter_t *pxWriter) |
Appends the end of the current JSON object (i.e. } ). More... | |
AzureIoTResult_t | AzureIoTJSONWriter_AppendEndArray (AzureIoTJSONWriter_t *pxWriter) |
Appends the end of the current JSON array (i.e. ] ). More... | |
The JSON writer used by the middleware for PnP properties.
AzureIoTResult_t AzureIoTJSONWriter_AppendBeginArray | ( | AzureIoTJSONWriter_t * | pxWriter | ) |
Appends the beginning of a JSON array (i.e. [
).
[in] | pxWriter | A pointer to an AzureIoTJSONWriter_t. |
eAzureIoTSuccess | Array start was appended successfully. |
AzureIoTResult_t AzureIoTJSONWriter_AppendBeginObject | ( | AzureIoTJSONWriter_t * | pxWriter | ) |
Appends the beginning of a JSON object (i.e. {
).
[in] | pxWriter | A pointer to an AzureIoTJSONWriter_t. |
eAzureIoTSuccess | Object start was appended successfully. |
AzureIoTResult_t AzureIoTJSONWriter_AppendBool | ( | AzureIoTJSONWriter_t * | pxWriter, |
bool | xValue | ||
) |
Appends a boolean value (as a JSON literal true
or false
).
[in] | pxWriter | A pointer to an AzureIoTJSONWriter_t. |
[in] | xValue | The value to be written as a JSON literal true or false . |
eAzureIoTSuccess | The bool was appended successfully. |
AzureIoTResult_t AzureIoTJSONWriter_AppendDouble | ( | AzureIoTJSONWriter_t * | pxWriter, |
double | xValue, | ||
uint16_t | usFractionalDigits | ||
) |
Appends a double
number value.
[in] | pxWriter | A pointer to an AzureIoTJSONWriter_t. |
[in] | xValue | The value to be written as a JSON number. |
[in] | usFractionalDigits | The number of digits of the value to write after the decimal point and truncate the rest. |
eAzureIoTSuccess | The number was appended successfully. |
NAN
and INFINITY
are not allowed and would lead to invalid JSON being written.usFractionalDigits
is large enough to allow the zero padding.usFractionalDigits
must be between 0 and 15 (inclusive). Any value passed in that is larger will be clamped down to 15. AzureIoTResult_t AzureIoTJSONWriter_AppendEndArray | ( | AzureIoTJSONWriter_t * | pxWriter | ) |
Appends the end of the current JSON array (i.e. ]
).
[in] | pxWriter | A pointer to an AzureIoTJSONWriter_t. |
eAzureIoTSuccess | Array end was appended successfully. |
AzureIoTResult_t AzureIoTJSONWriter_AppendEndObject | ( | AzureIoTJSONWriter_t * | pxWriter | ) |
Appends the end of the current JSON object (i.e. }
).
[in] | pxWriter | A pointer to an AzureIoTJSONWriter_t. |
eAzureIoTSuccess | Object end was appended successfully. |
AzureIoTResult_t AzureIoTJSONWriter_AppendInt32 | ( | AzureIoTJSONWriter_t * | pxWriter, |
int32_t | lValue | ||
) |
Appends an int32_t
number value.
[in] | pxWriter | A pointer to an AzureIoTJSONWriter_t. |
[in] | lValue | The value to be written as a JSON number. |
eAzureIoTSuccess | The number was appended successfully. |
AzureIoTResult_t AzureIoTJSONWriter_AppendJSONText | ( | AzureIoTJSONWriter_t * | pxWriter, |
const uint8_t * | pucJSON, | ||
uint32_t | ulJSONLen | ||
) |
Appends an existing UTF-8 encoded JSON text into the buffer, useful for appending nested JSON.
[in] | pxWriter | A pointer to an AzureIoTJSONWriter_t. |
[in] | pucJSON | A pointer to single, possibly nested, valid, UTF-8 encoded, JSON value to be written as is, without any formatting or spacing changes. No modifications are made to this text, including escaping. |
[in] | ulJSONLen | Length of pucJSON . |
eAzureIoTSuccess | The provided json_text was appended successfully. |
AzureIoTResult_t AzureIoTJSONWriter_AppendNull | ( | AzureIoTJSONWriter_t * | pxWriter | ) |
Appends the JSON literal null
.
[in] | pxWriter | A pointer to an AzureIoTJSONWriter_t. |
eAzureIoTSuccess | null was appended successfully. |
AzureIoTResult_t AzureIoTJSONWriter_AppendPropertyName | ( | AzureIoTJSONWriter_t * | pxWriter, |
const uint8_t * | pusValue, | ||
uint32_t | ulValueLen | ||
) |
Appends the UTF-8 property name (as a JSON string) which is the first part of a name/value pair of a JSON object.
[in] | pxWriter | A pointer to an AzureIoTJSONWriter_t. |
[in] | pusValue | The UTF-8 encoded property name of the JSON value to be written. The name is escaped before writing. |
[in] | ulValueLen | Length of name. |
eAzureIoTSuccess | The property name was appended successfully. |
AzureIoTResult_t AzureIoTJSONWriter_AppendPropertyWithBoolValue | ( | AzureIoTJSONWriter_t * | pxWriter, |
const uint8_t * | pucPropertyName, | ||
uint32_t | ulPropertyNameLength, | ||
bool | usValue | ||
) |
Appends the UTF-8 property name and value where value is boolean.
[in] | pxWriter | A pointer to an AzureIoTJSONWriter_t. |
[in] | pucPropertyName | The UTF-8 encoded property name of the JSON value to be written. The name is escaped before writing. |
[in] | ulPropertyNameLength | Length of pucPropertyName. |
[in] | usValue | The value to be written as a JSON literal true or false . |
eAzureIoTSuccess | The property name and bool value was appended successfully. |
AzureIoTResult_t AzureIoTJSONWriter_AppendPropertyWithDoubleValue | ( | AzureIoTJSONWriter_t * | pxWriter, |
const uint8_t * | pucPropertyName, | ||
uint32_t | ulPropertyNameLength, | ||
double | xValue, | ||
uint16_t | usFractionalDigits | ||
) |
Appends the UTF-8 property name and value where value is double.
[in] | pxWriter | A pointer to an AzureIoTJSONWriter_t. |
[in] | pucPropertyName | The UTF-8 encoded property name of the JSON value to be written. The name is escaped before writing. |
[in] | ulPropertyNameLength | Length of pucPropertyName. |
[in] | xValue | The value to be written as a JSON number. |
[in] | usFractionalDigits | The number of digits of the value to write after the decimal point and truncate the rest. |
eAzureIoTSuccess | The property name and double value was appended successfully. |
AzureIoTResult_t AzureIoTJSONWriter_AppendPropertyWithInt32Value | ( | AzureIoTJSONWriter_t * | pxWriter, |
const uint8_t * | pucPropertyName, | ||
uint32_t | ulPropertyNameLength, | ||
int32_t | lValue | ||
) |
Appends the UTF-8 property name and value where value is int32.
[in] | pxWriter | A pointer to an AzureIoTJSONWriter_t. |
[in] | pucPropertyName | The UTF-8 encoded property name of the JSON value to be written. The name is escaped before writing. |
[in] | ulPropertyNameLength | Length of pucPropertyName. |
[in] | lValue | The value to be written as a JSON number. |
eAzureIoTSuccess | The property name and int32 value was appended successfully. |
AzureIoTResult_t AzureIoTJSONWriter_AppendPropertyWithStringValue | ( | AzureIoTJSONWriter_t * | pxWriter, |
const uint8_t * | pucPropertyName, | ||
uint32_t | ulPropertyNameLength, | ||
const uint8_t * | pucValue, | ||
uint32_t | ulValueLen | ||
) |
Appends the UTF-8 property name and value where value is string.
[in] | pxWriter | A pointer to an AzureIoTJSONWriter_t. |
[in] | pucPropertyName | The UTF-8 encoded property name of the JSON value to be written. The name is escaped before writing. |
[in] | ulPropertyNameLength | Length of pucPropertyName. |
[in] | pucValue | The UTF-8 encoded property name of the JSON value to be written. The name is escaped before writing. |
[in] | ulValueLen | Length of value. |
eAzureIoTSuccess | The property name and string value was appended successfully. |
AzureIoTResult_t AzureIoTJSONWriter_AppendString | ( | AzureIoTJSONWriter_t * | pxWriter, |
const uint8_t * | pucValue, | ||
uint32_t | ulValueLen | ||
) |
Appends the UTF-8 text value (as a JSON string) into the buffer.
[in] | pxWriter | A pointer to an AzureIoTJSONWriter_t. |
[in] | pucValue | Pointer of UCHAR buffer that contains UTF-8 encoded value to be written as a JSON string. The value is escaped before writing. |
[in] | ulValueLen | Length of value. |
eAzureIoTSuccess | The string value was appended successfully. |
int32_t AzureIoTJSONWriter_GetBytesUsed | ( | AzureIoTJSONWriter_t * | pxWriter | ) |
Returns the length containing the JSON text written to the underlying buffer.
[in] | pxWriter | A pointer to an AzureIoTJSONWriter_t. |
AzureIoTResult_t AzureIoTJSONWriter_Init | ( | AzureIoTJSONWriter_t * | pxWriter, |
uint8_t * | pucBuffer, | ||
uint32_t | ulBufferSize | ||
) |
Initializes an AzureIoTJSONWriter_t which writes JSON text into a buffer passed.
[out] | pxWriter | A pointer to an AzureIoTJSONWriter_t the instance to initialize. |
[in] | pucBuffer | A buffer pointer to which JSON text will be written. |
[in] | ulBufferSize | Length of buffer. |
eAzureIoTSuccess | Successfully initialized JSON writer. |