# Azure IoT JSON ## Azure IoT JSON Reader **nx_azure_iot_json_reader_with_buffer_init** ***
Initializes an #NX_AZURE_IOT_JSON_READER to read the JSON payload contained within the provided buffer.
**Parameters** | Name | Description | | - |:-| | reader_ptr [out] | A pointer to an #NX_AZURE_IOT_JSON_READER instance to initialize. | | buffer_ptr [in] | An pointer to buffer containing the JSON text to read. | | buffer_len [in] | Length of buffer. | **Return Values** * NX_AZURE_IOT_SUCCESS Successfully initialized JSON reader. **Allowed From** Initialization, Threads **Example** **See Also** **nx_azure_iot_json_reader_init** ***Initializes an #NX_AZURE_IOT_JSON_READER to read the JSON payload contained within #NX_PACKET
**Parameters** | Name | Description | | - |:-| | reader_ptr [out] | A pointer to an #NX_AZURE_IOT_JSON_READER instance to initialize. | | packet_ptr [in] | A pointer to #NX_PACKET containing the JSON text. | **Return Values** * NX_AZURE_IOT_SUCCESS Successfully initialized JSON reader. **Allowed From** Threads **Example** **See Also** **nx_azure_iot_json_reader_deinit** ***De-initializes an #NX_AZURE_IOT_JSON_READER
**Parameters** | Name | Description | | - |:-| | reader_ptr [in] | A pointer to an #NX_AZURE_IOT_JSON_READER instance to de-initialize | **Return Values** * NX_AZURE_IOT_SUCCESS Successfully de-initialized JSON reader. **Allowed From** Threads **Example** **See Also** **nx_azure_iot_json_reader_next_token** ***Reads the next token in the JSON text and updates the reader state.
**Parameters** | Name | Description | | - |:-| | reader_ptr [in] | A pointer to an #NX_AZURE_IOT_JSON_READER instance containing the JSON to read. | **Return Values** * NX_AZURE_IOT_SUCCESS The token was read successfully. **Allowed From** Threads **Example** **See Also** **nx_azure_iot_json_reader_skip_children** ***Reads and skips over any nested JSON elements.
**Parameters** | Name | Description | | - |:-| | reader_ptr [in] | A pointer to an #NX_AZURE_IOT_JSON_READER instance containing the JSON to read. | **Return Values** * NX_AZURE_IOT_SUCCESS The children of the current JSON token are skipped successfully. **Allowed From** Threads **Example** **See Also** **nx_azure_iot_json_reader_token_bool_get** ***Gets the JSON token's boolean value.
**Parameters** | Name | Description | | - |:-| | reader_ptr [in] | A pointer to an #NX_AZURE_IOT_JSON_READER instance containing the JSON to read. | | value_ptr [out] | A pointer to a variable to receive the value. | **Return Values** * NX_AZURE_IOT_SUCCESS The boolean value is returned. **Allowed From** Threads **Example** **See Also** **nx_azure_iot_json_reader_token_uint32_get** ***Gets the JSON token's number as a 32-bit unsigned integer.
**Parameters** | Name | Description | | - |:-| | reader_ptr [in] | A pointer to an #NX_AZURE_IOT_JSON_READER instance containing the JSON to read. | | value_ptr [out] | A pointer to a variable to receive the value. | **Return Values** * NX_AZURE_IOT_SUCCESS The number is returned. **Allowed From** Threads **Example** **See Also** **nx_azure_iot_json_reader_token_int32_get** ***Gets the JSON token's number as a 32-bit signed integer.
**Parameters** | Name | Description | | - |:-| | reader_ptr [in] | A pointer to an #NX_AZURE_IOT_JSON_READER instance containing the JSON to read. | | value_ptr [out] | A pointer to a variable to receive the value. | **Return Values** * NX_AZURE_IOT_SUCCESS The number is returned. **Allowed From** Threads **Example** **See Also** **nx_azure_iot_json_reader_token_double_get** ***Gets the JSON token's number as a `double`.
**Parameters** | Name | Description | | - |:-| | reader_ptr [in] | A pointer to an #NX_AZURE_IOT_JSON_READER instance containing the JSON to read. | | value_ptr [out] | A pointer to a variable to receive the value. | **Return Values** * NX_AZURE_IOT_SUCCESS The number is returned. **Allowed From** Threads **Example** **See Also** **nx_azure_iot_json_reader_token_string_get** ***Gets the JSON token's string after unescaping it, if required.
**Parameters** | Name | Description | | - |:-| | reader_ptr [in] | A pointer to an #NX_AZURE_IOT_JSON_READER instance containing the JSON to read. | | buffer_ptr [out] | A pointer to a buffer where the string should be copied into. | | buffer_size [in] | The maximum available space within the buffer referred to by buffer_ptr. | | bytes_copied [out] | Contains the number of bytes written to the destination which denote the length of the unescaped string. | **Return Values** * NX_AZURE_IOT_SUCCESS The string is returned. **Allowed From** Threads **Example** **See Also** **nx_azure_iot_json_reader_token_is_text_equal** ***Determines whether the unescaped JSON token value that the #NX_AZURE_IOT_JSON_READER points to is equal to the expected text within the provided buffer bytes by doing a case-sensitive comparison.
**Parameters** | Name | Description | | - |:-| | reader_ptr [in] | A pointer to an #NX_AZURE_IOT_JSON_READER instance containing the JSON to read. | | expected_text_ptr [in] | A pointer to lookup text to compare the token against. | | expected_text_len [in] | Length of expected_text_ptr. | **Return Values** * NX_TRUE If the current JSON token value in the JSON source semantically matches the expected lookup text. * NX_FALSE Otherwise. **Allowed From** Threads **Example** **See Also** **nx_azure_iot_json_reader_token_type** ***Determines type of token currently #NX_AZURE_IOT_JSON_READER points to..
**Parameters** | Name | Description | | - |:-| | reader_ptr [in] | A pointer to an #NX_AZURE_IOT_JSON_READER instance containing the JSON to read. | **Return Values** * NX_AZURE_IOT_READER_TOKEN_NONE There is no value. * NX_AZURE_IOT_READER_TOKEN_BEGIN_OBJECT The token kind is the start of a JSON object. * NX_AZURE_IOT_READER_TOKEN_END_OBJECT The token kind is the end of a JSON object. * NX_AZURE_IOT_READER_TOKEN_BEGIN_ARRAY The token kind is the start of a JSON array. * NX_AZURE_IOT_READER_TOKEN_END_ARRAY The token kind is the end of a JSON array. * NX_AZURE_IOT_READER_TOKEN_PROPERTY_NAME The token kind is a JSON property name. * NX_AZURE_IOT_READER_TOKEN_STRING The token kind is a JSON string. * NX_AZURE_IOT_READER_TOKEN_NUMBER The token kind is a JSON number. * NX_AZURE_IOT_READER_TOKEN_TRUE The token kind is the JSON literal `true`. * NX_AZURE_IOT_READER_TOKEN_FALSE The token kind is the JSON literal `false`. * NX_AZURE_IOT_READER_TOKEN_NULL The token kind is the JSON literal `null`. **Allowed From** Threads **Example** **See Also** ## Azure IoT JSON Writer **nx_azure_iot_json_writer_init** ***Initializes an #NX_AZURE_IOT_JSON_WRITER which writes JSON text into a NX_PACKET.
**Parameters** | Name | Description | | - |:-| | json_writer_ptr [out] | A pointer to an #NX_AZURE_IOT_JSON_WRITER the instance to initialize. | | packet_ptr [in] | A pointer to #NX_PACKET. | | wait_option [in] | Ticks to wait for allocating next packet | **Return Values** * NX_AZURE_IOT_SUCCESS Successfully initialized JSON writer. **Allowed From** Initialization, Threads **Example** **See Also** **nx_azure_iot_json_writer_with_buffer_init** ***Initializes an #NX_AZURE_IOT_JSON_WRITER which writes JSON text into a buffer passed.
**Parameters** | Name | Description | | - |:-| | json_writer_ptr [out] | A pointer to an #NX_AZURE_IOT_JSON_WRITER the instance to initialize. | | buffer_ptr [in] | A buffer pointer to which JSON text will be written. | | buffer_len [in] | Length of buffer. | **Return Values** * NX_AZURE_IOT_SUCCESS Successfully initialized JSON writer. **Allowed From** Initialization, Threads **Example** **See Also** **nx_azure_iot_json_writer_deinit** ***Deinitializes an #NX_AZURE_IOT_JSON_WRITER.
**Parameters** | Name | Description | | - |:-| | json_writer_ptr [in] | A pointer to an #NX_AZURE_IOT_JSON_WRITER the instance to de-initialize. | **Return Values** * NX_AZURE_IOT_SUCCESS Successfully de-initialized JSON writer. **Allowed From** Initialization, Threads **Example** **See Also** **nx_azure_iot_json_writer_append_property_with_int32_value** ***Appends the UTF-8 property name and value where value is int32.
**Parameters** | Name | Description | | - |:-| | json_writer_ptr [in] | A pointer to an #NX_AZURE_IOT_JSON_WRITER. | | property_name [in] | The UTF-8 encoded property name of the JSON value to be written. The name is escaped before writing | | property_name_len [in] | Length of property_name. | | value [in] | The value to be written as a JSON number. | **Return Values** * NX_AZURE_IOT_SUCCESS The property name and int32 value was appended successfully. **Allowed From** Initialization, Threads **Example** **See Also** **nx_azure_iot_json_writer_append_property_with_double_value** ***Appends the UTF-8 property name and value where value is double.
**Parameters** | Name | Description | | - |:-| | json_writer_ptr [in] | A pointer to an #NX_AZURE_IOT_JSON_WRITER. | | property_name [in] | The UTF-8 encoded property name of the JSON value to be written. The name is escaped before writing | | property_name_len [in] | Length of property_name. | | value [in] | The value to be written as a JSON number. | | fractional_digits [in] | The number of digits of the value to write after the decimal point and truncate the rest. | **Return Values** * NX_AZURE_IOT_SUCCESS The property name and double value was appended successfully. **Allowed From** Initialization, Threads **Example** **See Also** **nx_azure_iot_json_writer_append_property_with_bool_value** ***Appends the UTF-8 property name and value where value is boolean.
**Parameters** | Name | Description | | - |:-| | json_writer_ptr [in] | A pointer to an #NX_AZURE_IOT_JSON_WRITER. | | property_name [in] | The UTF-8 encoded property name of the JSON value to be written. The name is escaped before writing | | property_name_len [in] | Length of property_name. | | value [in] | The value to be written as a JSON literal `true` or `false`. | **Return Values** * NX_AZURE_IOT_SUCCESS The property name and bool value was appended successfully. **Allowed From** Initialization, Threads **Example** **See Also** **nx_azure_iot_json_writer_append_property_with_string_value** ***Appends the UTF-8 property name and value where value is string.
**Parameters** | Name | Description | | - |:-| | json_writer_ptr [in] | A pointer to an #NX_AZURE_IOT_JSON_WRITER. | | property_name [in] | The UTF-8 encoded property name of the JSON value to be written. The name is escaped before writing | | property_name_len [in] | Length of property_name. | | value [in] | The UTF-8 encoded property name of the JSON value to be written. The name is escaped before writing. | | value_len [in] | Length of value. | **Return Values** * NX_AZURE_IOT_SUCCESS The property name and string value was appended successfully. **Allowed From** Initialization, Threads **Example** **See Also** **nx_azure_iot_json_writer_get_bytes_used** ***Returns the length containing the JSON text written to the underlying buffer.
**Parameters** | Name | Description | | - |:-| | json_writer_ptr [in] | A pointer to an #NX_AZURE_IOT_JSON_WRITER. | **Return Values** * UINT Value containing the length of JSON text built so far. **Allowed From** Initialization, Threads **Example** **See Also** **nx_azure_iot_json_writer_append_string** ***Appends the UTF-8 text value (as a JSON string) into the buffer.
**Parameters** | Name | Description | | - |:-| | json_writer_ptr [in] | A pointer to an #NX_AZURE_IOT_JSON_WRITER. | | value [in] | Pointer of UCHAR buffer that contains UTF-8 encoded value to be written as a JSON string The value is escaped before writing. | | value_len [in] | Length of value. | **Return Values** * NX_AZURE_IOT_SUCCESS The string value was appended successfully. **Allowed From** Initialization, Threads **Example** **See Also** **nx_azure_iot_json_writer_append_json_text** ***Appends an existing UTF-8 encoded JSON text into the buffer, useful for appending nested JSON.
**Parameters** | Name | Description | | - |:-| | json_writer_ptr [in] | A pointer to an #NX_AZURE_IOT_JSON_WRITER. | | json [in] | 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. | | json_len [in] | Length of json. | **Return Values** * NX_AZURE_IOT_SUCCESS The provided json_text was appended successfully. **Allowed From** Initialization, Threads **Example** **See Also** **nx_azure_iot_json_writer_append_property_name** ***Appends the UTF-8 property name (as a JSON string) which is the first part of a name/value pair of a JSON object.
**Parameters** | Name | Description | | - |:-| | json_writer_ptr [in] | A pointer to an #NX_AZURE_IOT_JSON_WRITER. | | value [in] | The UTF-8 encoded property name of the JSON value to be written. The name is escaped before writing. | | value_len [in] | Length of property name. | **Return Values** * NX_AZURE_IOT_SUCCESS The property name was appended successfully. **Allowed From** Initialization, Threads **Example** **See Also** **nx_azure_iot_json_writer_append_bool** ***Appends a boolean value (as a JSON literal `true` or `false`).
**Parameters** | Name | Description | | - |:-| | json_writer_ptr [in] | A pointer to an #NX_AZURE_IOT_JSON_WRITER. | | value [in] | The value to be written as a JSON literal `true` or `false`. | **Return Values** * NX_AZURE_IOT_SUCCESS The bool was appended successfully. **Allowed From** Initialization, Threads **Example** **See Also** **nx_azure_iot_json_writer_append_int32** ***Appends an `int32_t` number value.
**Parameters** | Name | Description | | - |:-| | json_writer_ptr [in] | A pointer to an #NX_AZURE_IOT_JSON_WRITER. | | value [in] | The value to be written as a JSON number. | **Return Values** * NX_AZURE_IOT_SUCCESS The number was appended successfully. **Allowed From** Initialization, Threads **Example** **See Also** **nx_azure_iot_json_writer_append_double** ***Appends a `double` number value.
**Parameters** | Name | Description | | - |:-| | json_writer_ptr [in] | A pointer to an #NX_AZURE_IOT_JSON_WRITER. | | value [in] | The value to be written as a JSON number. | | fractional_digits [in] | The number of digits of the value to write after the decimal point and truncate the rest. | **Return Values** * NX_AZURE_IOT_SUCCESS The number was appended successfully. **Allowed From** Initialization, Threads **Example** **See Also** **nx_azure_iot_json_writer_append_null** ***Appends the JSON literal `null`.
**Parameters** | Name | Description | | - |:-| | json_writer_ptr [in] | A pointer to an #NX_AZURE_IOT_JSON_WRITER. | **Return Values** * NX_AZURE_IOT_SUCCESS `null` was appended successfully. **Allowed From** Initialization, Threads **Example** **See Also** **nx_azure_iot_json_writer_append_begin_object** ***Appends the beginning of a JSON object (i.e. `{`).
**Parameters** | Name | Description | | - |:-| | json_writer_ptr [in] | A pointer to an #NX_AZURE_IOT_JSON_WRITER. | **Return Values** * NX_AZURE_IOT_SUCCESS Object start was appended successfully. **Allowed From** Initialization, Threads **Example** **See Also** **nx_azure_iot_json_writer_append_begin_array** ***Appends the beginning of a JSON array (i.e. `[`).
**Parameters** | Name | Description | | - |:-| | json_writer_ptr [in] | A pointer to an #NX_AZURE_IOT_JSON_WRITER. | **Return Values** * NX_AZURE_IOT_SUCCESS Array start was appended successfully. **Allowed From** Initialization, Threads **Example** **See Also** **nx_azure_iot_json_writer_append_end_object** ***Appends the end of the current JSON object (i.e. `}`).
**Parameters** | Name | Description | | - |:-| | json_writer_ptr [in] | A pointer to an #NX_AZURE_IOT_JSON_WRITER. | **Return Values** * NX_AZURE_IOT_SUCCESS Object end was appended successfully. **Allowed From** Initialization, Threads **Example** **See Also** **nx_azure_iot_json_writer_append_end_array** ***Appends the end of the current JSON array (i.e. `]`).
**Parameters** | Name | Description | | - |:-| | json_writer_ptr [in] | A pointer to an #NX_AZURE_IOT_JSON_WRITER. | **Return Values** * NX_AZURE_IOT_SUCCESS Array end was appended successfully. **Allowed From** Initialization, Threads **Example** **See Also**