Azure IoT middleware for FreeRTOS
|
The JSON reader 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 | AzureIoTJSONReader |
The struct to use for Azure IoT JSON reader functionality. More... | |
Typedefs | |
typedef enum AzureIoTJSONTokenType | AzureIoTJSONTokenType_t |
Defines symbols for the various kinds of JSON tokens that make up any JSON text. | |
typedef struct AzureIoTJSONReader | AzureIoTJSONReader_t |
The struct to use for Azure IoT JSON reader functionality. | |
Enumerations | |
enum | AzureIoTJSONTokenType { eAzureIoTJSONTokenNONE = AZ_JSON_TOKEN_NONE , eAzureIoTJSONTokenBEGIN_OBJECT = AZ_JSON_TOKEN_BEGIN_OBJECT , eAzureIoTJSONTokenEND_OBJECT = AZ_JSON_TOKEN_END_OBJECT , eAzureIoTJSONTokenBEGIN_ARRAY = AZ_JSON_TOKEN_BEGIN_ARRAY , eAzureIoTJSONTokenEND_ARRAY = AZ_JSON_TOKEN_END_ARRAY , eAzureIoTJSONTokenPROPERTY_NAME = AZ_JSON_TOKEN_PROPERTY_NAME , eAzureIoTJSONTokenSTRING = AZ_JSON_TOKEN_STRING , eAzureIoTJSONTokenNUMBER = AZ_JSON_TOKEN_NUMBER , eAzureIoTJSONTokenTRUE = AZ_JSON_TOKEN_TRUE , eAzureIoTJSONTokenFALSE = AZ_JSON_TOKEN_FALSE , eAzureIoTJSONTokenNULL = AZ_JSON_TOKEN_NULL } |
Defines symbols for the various kinds of JSON tokens that make up any JSON text. | |
Functions | |
AzureIoTResult_t | AzureIoTJSONReader_Init (AzureIoTJSONReader_t *pxReader, const uint8_t *pucBuffer, uint32_t ulBufferSize) |
Initializes an AzureIoTJSONReader_t to read the JSON payload contained within the provided buffer. More... | |
AzureIoTResult_t | AzureIoTJSONReader_NextToken (AzureIoTJSONReader_t *pxReader) |
Reads the next token in the JSON text and updates the reader state. More... | |
AzureIoTResult_t | AzureIoTJSONReader_SkipChildren (AzureIoTJSONReader_t *pxReader) |
Reads and skips over any nested JSON elements. More... | |
AzureIoTResult_t | AzureIoTJSONReader_GetTokenBool (AzureIoTJSONReader_t *pxReader, bool *pxValue) |
Gets the JSON token's boolean value. More... | |
AzureIoTResult_t | AzureIoTJSONReader_GetTokenInt32 (AzureIoTJSONReader_t *pxReader, int32_t *plValue) |
Gets the JSON token's number as a 32-bit signed integer. More... | |
AzureIoTResult_t | AzureIoTJSONReader_GetTokenDouble (AzureIoTJSONReader_t *pxReader, double *pxValue) |
Gets the JSON token's number as a double . More... | |
AzureIoTResult_t | AzureIoTJSONReader_GetTokenString (AzureIoTJSONReader_t *pxReader, uint8_t *pucBuffer, uint32_t ulBufferSize, uint32_t *pusBytesCopied) |
Gets the JSON token's string after unescaping it, if required. More... | |
bool | AzureIoTJSONReader_TokenIsTextEqual (AzureIoTJSONReader_t *pxReader, const uint8_t *pucExpectedText, uint32_t ulExpectedTextLength) |
Determines whether the unescaped JSON token value that the AzureIoTJSONReader_t points to is equal to the expected text within the provided buffer bytes by doing a case-sensitive comparison. More... | |
AzureIoTResult_t | AzureIoTJSONReader_TokenType (AzureIoTJSONReader_t *pxReader, AzureIoTJSONTokenType_t *pxTokenType) |
Determines type of token currently AzureIoTJSONReader_t points to. More... | |
The JSON reader used by the middleware for PnP properties.
AzureIoTResult_t AzureIoTJSONReader_GetTokenBool | ( | AzureIoTJSONReader_t * | pxReader, |
bool * | pxValue | ||
) |
Gets the JSON token's boolean value.
[in] | pxReader | A pointer to an AzureIoTJSONReader_t instance. |
[out] | pxValue | A pointer to a boolean to receive the value. |
eAzureIoTSuccess | The boolean value is returned. |
AzureIoTResult_t AzureIoTJSONReader_GetTokenDouble | ( | AzureIoTJSONReader_t * | pxReader, |
double * | pxValue | ||
) |
Gets the JSON token's number as a double
.
[in] | pxReader | A pointer to an AzureIoTJSONReader_t instance. |
[out] | pxValue | A pointer to a variable to receive the value. |
eAzureIoTSuccess | The number is returned. |
AzureIoTResult_t AzureIoTJSONReader_GetTokenInt32 | ( | AzureIoTJSONReader_t * | pxReader, |
int32_t * | plValue | ||
) |
Gets the JSON token's number as a 32-bit signed integer.
[in] | pxReader | A pointer to an AzureIoTJSONReader_t instance. |
[out] | plValue | A pointer to a variable to receive the value. |
eAzureIoTSuccess | The number is returned. |
AzureIoTResult_t AzureIoTJSONReader_GetTokenString | ( | AzureIoTJSONReader_t * | pxReader, |
uint8_t * | pucBuffer, | ||
uint32_t | ulBufferSize, | ||
uint32_t * | pusBytesCopied | ||
) |
Gets the JSON token's string after unescaping it, if required.
[in] | pxReader | A pointer to an AzureIoTJSONReader_t instance. |
[out] | pucBuffer | A pointer to a buffer where the string should be copied into. |
[in] | ulBufferSize | The maximum available space within the buffer referred to by pucBuffer. |
[out] | pusBytesCopied | Contains the number of bytes written to the destination which denote the length of the unescaped string. |
eAzureIoTSuccess | The property name was appended successfully. |
AzureIoTResult_t AzureIoTJSONReader_Init | ( | AzureIoTJSONReader_t * | pxReader, |
const uint8_t * | pucBuffer, | ||
uint32_t | ulBufferSize | ||
) |
Initializes an AzureIoTJSONReader_t to read the JSON payload contained within the provided buffer.
[out] | pxReader | A pointer to an AzureIoTJSONReader_t instance to initialize. |
[in] | pucBuffer | A pointer to a buffer containing the JSON text to read. |
[in] | ulBufferSize | Length of buffer. |
eAzureIoTSuccess | The AzureIoTJSONReader_t is initialized successfully. |
other | Initialization failed. |
AzureIoTResult_t AzureIoTJSONReader_NextToken | ( | AzureIoTJSONReader_t * | pxReader | ) |
Reads the next token in the JSON text and updates the reader state.
[in] | pxReader | A pointer to an AzureIoTJSONReader_t instance containing the JSON to read. |
eAzureIoTSuccess | The token was read successfully. |
AzureIoTResult_t AzureIoTJSONReader_SkipChildren | ( | AzureIoTJSONReader_t * | pxReader | ) |
Reads and skips over any nested JSON elements.
[in] | pxReader | A pointer to an AzureIoTJSONReader_t instance containing the JSON to read. |
eAzureIoTSuccess | The children of the current JSON token are skipped successfully. |
bool AzureIoTJSONReader_TokenIsTextEqual | ( | AzureIoTJSONReader_t * | pxReader, |
const uint8_t * | pucExpectedText, | ||
uint32_t | ulExpectedTextLength | ||
) |
Determines whether the unescaped JSON token value that the AzureIoTJSONReader_t points to is equal to the expected text within the provided buffer bytes by doing a case-sensitive comparison.
[in] | pxReader | A pointer to an AzureIoTJSONReader_t instance containing the JSON string token. |
[in] | pucExpectedText | A pointer to lookup text to compare the token against. |
[in] | ulExpectedTextLength | Length of pucExpectedText . |
AzureIoTResult_t AzureIoTJSONReader_TokenType | ( | AzureIoTJSONReader_t * | pxReader, |
AzureIoTJSONTokenType_t * | pxTokenType | ||
) |
Determines type of token currently AzureIoTJSONReader_t points to.
[in] | pxReader | A pointer to an AzureIoTJSONReader_t instance. |
[out] | pxTokenType | The returned type of the token. |