Azure SDK for Embedded C
Data Fields
az_json_token Struct Reference

Represents a JSON token. The kind field indicates the type of the JSON token and the slice represents the portion of the JSON payload that points to the token value. More...

#include <az_json.h>

Data Fields

az_span slice
 
az_json_token_kind kind
 
int32_t size
 
bool is_multisegment
 
bool string_has_escaped_chars
 
az_spanpointer_to_first_buffer
 
int32_t start_buffer_index
 The segment index within the non-contiguous JSON payload where this token starts.
 
int32_t start_buffer_offset
 The offset within the particular segment within which this token starts.
 
int32_t end_buffer_index
 The segment index within the non-contiguous JSON payload where this token ends.
 
int32_t end_buffer_offset
 The offset within the particular segment within which this token ends.
 

Detailed Description

Represents a JSON token. The kind field indicates the type of the JSON token and the slice represents the portion of the JSON payload that points to the token value.

Remarks
An instance of az_json_token must not outlive the lifetime of the az_json_reader it came from.

Field Documentation

◆ is_multisegment

bool az_json_token::is_multisegment

A flag to indicate whether the JSON token straddles more than one buffer segment and is split amongst non-contiguous buffers. For tokens created from input JSON payloads within a contiguous buffer, this field is always false.

◆ kind

az_json_token_kind az_json_token::kind

This read-only field gives access to the type of the token returned by the az_json_reader, and it shouldn't be modified by the caller.

◆ pointer_to_first_buffer

az_span* az_json_token::pointer_to_first_buffer

This is the first segment in the entire JSON payload, if it was non-contiguous. Otherwise, its set to AZ_SPAN_EMPTY.

◆ size

int32_t az_json_token::size

This read-only field gives access to the size of the JSON text slice that represents the token value, and it shouldn't be modified by the caller. This is useful if the token straddles non-contiguous buffers, to figure out what sized destination buffer to provide when calling az_json_token_copy_into_span().

◆ slice

az_span az_json_token::slice

This read-only field gives access to the slice of the JSON text that represents the token value, and it shouldn't be modified by the caller. If the token straddles non-contiguous buffers, this is set to the partial token value available in the last segment. The user can call az_json_token_copy_into_span() to get the token value into a contiguous buffer. In the case of JSON strings, the slice does not include the surrounding quotes.

◆ string_has_escaped_chars

bool az_json_token::string_has_escaped_chars

A flag to indicate whether the JSON string contained any escaped characters, used as an optimization to avoid redundant checks. It is meaningless for any other token kind.


The documentation for this struct was generated from the following file: