Go to the documentation of this file.
25 #include <azure/core/_az_cfg_prefix.h>
56 uint64_t az_json_stack;
57 int32_t current_depth;
243 int32_t destination_max_size,
244 int32_t* out_string_length);
383 az_span first_destination_buffer,
557 int32_t fractional_digits);
761 int32_t number_of_buffers,
818 #include <azure/core/_az_cfg_suffix.h>
AZ_NODISCARD az_result az_json_token_get_double(az_json_token const *json_token, double *out_value)
Gets the JSON token's number as a double.
AZ_NODISCARD az_result az_json_writer_append_end_array(az_json_writer *ref_json_writer)
Appends the end of the current JSON array (i.e. ]).
Definition of az_result and helper functions.
az_span * pointer_to_first_buffer
Definition: az_json.h:105
int32_t bytes_written
The bytes written in the current destination buffer.
Definition: az_json.h:317
@ AZ_JSON_TOKEN_FALSE
The token kind is the JSON literal false.
Definition: az_json.h:41
Returns the JSON tokens contained within a JSON buffer, one at a time.
Definition: az_json.h:664
AZ_NODISCARD az_result az_json_writer_append_double(az_json_writer *ref_json_writer, double value, int32_t fractional_digits)
Appends a double number value.
AZ_NODISCARD az_result az_json_reader_next_token(az_json_reader *ref_json_reader)
Reads the next token in the JSON text and updates the reader state.
Allows the user to define custom behavior when writing JSON using the az_json_writer.
Definition: az_json.h:269
Provides forward-only, non-cached writing of UTF-8 encoded JSON text into the provided buffer.
Definition: az_json.h:305
int32_t end_buffer_offset
The offset within the particular segment within which this token ends.
Definition: az_json.h:117
AZ_NODISCARD AZ_INLINE az_json_writer_options az_json_writer_options_default()
Gets the default json writer options which builds minimized JSON (with no extra white space) accordin...
Definition: az_json.h:286
AZ_NODISCARD az_result az_json_writer_append_string(az_json_writer *ref_json_writer, az_span value)
Appends the UTF-8 text value (as a JSON string) into the buffer.
AZ_NODISCARD az_result az_json_writer_append_end_object(az_json_writer *ref_json_writer)
Appends the end of the current JSON object (i.e. }).
AZ_NODISCARD az_result az_json_writer_append_property_name(az_json_writer *ref_json_writer, az_span name)
Appends the UTF-8 property name (as a JSON string) which is the first part of a name/value pair of a ...
AZ_NODISCARD az_result az_json_token_get_uint32(az_json_token const *json_token, uint32_t *out_value)
Gets the JSON token's number as a 32-bit unsigned integer.
@ AZ_JSON_TOKEN_BEGIN_OBJECT
The token kind is the start of a JSON object.
Definition: az_json.h:33
az_span * json_buffers
Definition: az_json.h:681
@ AZ_JSON_TOKEN_END_ARRAY
The token kind is the end of a JSON array.
Definition: az_json.h:36
int32_t total_bytes_consumed
Definition: az_json.h:696
AZ_NODISCARD az_result az_json_writer_append_begin_object(az_json_writer *ref_json_writer)
Appends the beginning of a JSON object (i.e. {).
int32_t az_result
The type represents the various success and error conditions.
Definition: az_result.h:46
Allows the user to define custom behavior when reading JSON using the az_json_reader.
Definition: az_json.h:629
az_json_token token
Definition: az_json.h:667
AZ_NODISCARD AZ_INLINE az_span az_json_writer_get_bytes_used_in_destination(az_json_writer const *json_writer)
Returns the az_span containing the JSON text written to the underlying buffer so far,...
Definition: az_json.h:406
int32_t end_buffer_index
The segment index within the non-contiguous JSON payload where this token ends.
Definition: az_json.h:114
@ AZ_JSON_TOKEN_END_OBJECT
The token kind is the end of a JSON object.
Definition: az_json.h:34
bool unused
Currently, this is unused, but needed as a placeholder since we can't have an empty struct.
Definition: az_json.h:633
bool unused
Currently, this is unused, but needed as a placeholder since we can't have an empty struct.
Definition: az_json.h:273
az_json_token_kind token_kind
Definition: az_json.h:331
bool need_comma
A state to remember when to emit a comma between JSON array and object elements.
Definition: az_json.h:327
AZ_NODISCARD az_result az_json_writer_chunked_init(az_json_writer *out_json_writer, az_span first_destination_buffer, az_span_allocator_fn allocator_callback, void *user_context, az_json_writer_options const *options)
Initializes an az_json_writer which writes JSON text into a destination that can contain non-contiguo...
AZ_NODISCARD az_result az_json_token_get_boolean(az_json_token const *json_token, bool *out_value)
Gets the JSON token's boolean.
az_result(* az_span_allocator_fn)(az_span_allocator_context *allocator_context, az_span *out_next_destination)
Defines the signature of the callback function that the caller must implement to provide the potentia...
Definition: az_span.h:531
@ AZ_JSON_TOKEN_STRING
The token kind is a JSON string.
Definition: az_json.h:38
int32_t current_depth
Definition: az_json.h:672
az_json_reader_options options
A copy of the options provided by the user.
Definition: az_json.h:706
int32_t number_of_buffers
Definition: az_json.h:685
AZ_NODISCARD az_span az_span_slice(az_span span, int32_t start_index, int32_t end_index)
Returns a new az_span which is a sub-span of the specified span.
int32_t total_bytes_written
Definition: az_json.h:309
AZ_NODISCARD az_result az_json_token_get_uint64(az_json_token const *json_token, uint64_t *out_value)
Gets the JSON token's number as a 64-bit unsigned integer.
@ AZ_JSON_TOKEN_PROPERTY_NAME
The token kind is a JSON property name.
Definition: az_json.h:37
AZ_NODISCARD AZ_INLINE az_json_reader_options az_json_reader_options_default()
Gets the default json reader options which reads the JSON strictly according to the JSON RFC.
Definition: az_json.h:646
_az_json_bit_stack bit_stack
A limited stack to track the depth and nested JSON objects or arrays read so far.
Definition: az_json.h:703
An az_span represents a contiguous byte buffer and is used for string manipulations,...
az_json_token_kind kind
Definition: az_json.h:84
@ AZ_JSON_TOKEN_NULL
The token kind is the JSON literal null.
Definition: az_json.h:42
int32_t buffer_index
Definition: az_json.h:689
int32_t start_buffer_offset
The offset within the particular segment within which this token starts.
Definition: az_json.h:111
void * user_context
Definition: az_json.h:324
AZ_NODISCARD az_result az_json_writer_append_json_text(az_json_writer *ref_json_writer, az_span json_text)
Appends an existing UTF-8 encoded JSON text into the buffer, useful for appending nested JSON.
az_span json_buffer
The first buffer containing the JSON payload.
Definition: az_json.h:677
AZ_NODISCARD az_result az_json_writer_append_begin_array(az_json_writer *ref_json_writer)
Appends the beginning of a JSON array (i.e. [).
AZ_NODISCARD az_result az_json_token_get_string(az_json_token const *json_token, char *destination, int32_t destination_max_size, int32_t *out_string_length)
Gets the JSON token's string after unescaping it, if required.
@ AZ_JSON_TOKEN_NUMBER
The token kind is a JSON number.
Definition: az_json.h:39
az_json_token_kind
Defines symbols for the various kinds of JSON tokens that make up any JSON text.
Definition: az_json.h:31
@ AZ_JSON_TOKEN_NONE
There is no value (as distinct from AZ_JSON_TOKEN_NULL).
Definition: az_json.h:32
bool string_has_escaped_chars
Definition: az_json.h:101
AZ_NODISCARD az_result az_json_writer_append_bool(az_json_writer *ref_json_writer, bool value)
Appends a boolean value (as a JSON literal true or false).
Represents a JSON token. The kind field indicates the type of the JSON token and the slice represents...
Definition: az_json.h:69
AZ_NODISCARD az_result az_json_writer_append_null(az_json_writer *ref_json_writer)
Appends the JSON literal null.
az_json_writer_options options
A copy of the options provided by the user.
Definition: az_json.h:339
int32_t size
Definition: az_json.h:90
az_span destination_buffer
The destination to write the JSON into.
Definition: az_json.h:314
az_span_allocator_fn allocator_callback
Allocator used to support non-contiguous buffer as a destination.
Definition: az_json.h:320
@ AZ_JSON_TOKEN_TRUE
The token kind is the JSON literal true.
Definition: az_json.h:40
@ AZ_JSON_TOKEN_BEGIN_ARRAY
The token kind is the start of a JSON array.
Definition: az_json.h:35
int32_t start_buffer_index
The segment index within the non-contiguous JSON payload where this token starts.
Definition: az_json.h:108
bool is_complex_json
Definition: az_json.h:700
bool is_multisegment
Definition: az_json.h:97
AZ_NODISCARD bool az_json_token_is_text_equal(az_json_token const *json_token, az_span expected_text)
Determines whether the unescaped JSON token value that the az_json_token points to is equal to the ex...
az_span az_json_token_copy_into_span(az_json_token const *json_token, az_span destination)
Copies the content of the token az_json_token to the destination az_span.
AZ_NODISCARD az_result az_json_reader_skip_children(az_json_reader *ref_json_reader)
Reads and skips over any nested JSON elements.
az_span slice
Definition: az_json.h:77
AZ_NODISCARD az_result az_json_reader_init(az_json_reader *out_json_reader, az_span json_buffer, az_json_reader_options const *options)
Initializes an az_json_reader to read the JSON payload contained within the provided buffer.
AZ_NODISCARD az_result az_json_token_get_int64(az_json_token const *json_token, int64_t *out_value)
Gets the JSON token's number as a 64-bit signed integer.
_az_json_bit_stack bit_stack
Definition: az_json.h:336
AZ_NODISCARD az_result az_json_writer_append_int32(az_json_writer *ref_json_writer, int32_t value)
Appends an int32_t number value.
AZ_NODISCARD az_result az_json_reader_chunked_init(az_json_reader *out_json_reader, az_span json_buffers[], int32_t number_of_buffers, az_json_reader_options const *options)
Initializes an az_json_reader to read the JSON payload contained within the provided set of discontig...
AZ_NODISCARD az_result az_json_token_get_int32(az_json_token const *json_token, int32_t *out_value)
Gets the JSON token's number as a 32-bit signed integer.
int32_t bytes_consumed
The number of bytes consumed so far in the current buffer segment.
Definition: az_json.h:692
AZ_NODISCARD az_result az_json_writer_init(az_json_writer *out_json_writer, az_span destination_buffer, az_json_writer_options const *options)
Initializes an az_json_writer which writes JSON text into a buffer.
Represents a "view" over a byte buffer that represents a contiguous region of memory....
Definition: az_span.h:33
AZ_NODISCARD az_span az_json_string_unescape(az_span json_string, az_span destination)
Unescapes the JSON string within the provided az_span.