File syn_json_write.c¶
FileList > src > syntropic > util > syn_json_write.c
Go to the source code of this file
Streaming JSON builder implementation.
#include "../util/syn_assert.h"#include "syn_json_write.h"#include <string.h>
Public Functions¶
| Type | Name |
|---|---|
| void | syn_json_arr_close (SYN_JsonWriter * w) Close a JSON array ] . |
| void | syn_json_arr_open (SYN_JsonWriter * w) Open a JSON array [ . |
| void | syn_json_init (SYN_JsonWriter * w, char * buf, size_t capacity) Initialize a JSON writer. |
| void | syn_json_key (SYN_JsonWriter * w, const char * key) Write a bare key "key": for nested objects/arrays. |
| void | syn_json_key_bool (SYN_JsonWriter * w, const char * key, bool val) Write "key":true or"key":false . |
| void | syn_json_key_int (SYN_JsonWriter * w, const char * key, int32_t val) Write "key":123 . |
| void | syn_json_key_null (SYN_JsonWriter * w, const char * key) Write "key":null . |
| void | syn_json_key_str (SYN_JsonWriter * w, const char * key, const char * val) Write "key":"value" . Escapes" and\\ in value. |
| void | syn_json_key_uint (SYN_JsonWriter * w, const char * key, uint32_t val) Write "key":123 (unsigned). |
| void | syn_json_obj_close (SYN_JsonWriter * w) Close a JSON object } . |
| void | syn_json_obj_open (SYN_JsonWriter * w) Open a JSON object { . |
| void | syn_json_val_bool (SYN_JsonWriter * w, bool val) Append a boolean value to an array. |
| void | syn_json_val_int (SYN_JsonWriter * w, int32_t val) Append an integer value to an array. |
| void | syn_json_val_str (SYN_JsonWriter * w, const char * val) Append a string value to an array. |
| void | syn_json_val_uint (SYN_JsonWriter * w, uint32_t val) Append an unsigned integer value to an array. |
Public Static Functions¶
| Type | Name |
|---|---|
| void | jw_comma (SYN_JsonWriter * w) Insert comma separator if needed. |
| void | jw_int (SYN_JsonWriter * w, int32_t val) Write a signed integer. |
| void | jw_putc (SYN_JsonWriter * w, char ch) Append a single char to the output buffer. |
| void | jw_puts (SYN_JsonWriter * w, const char * s) Append a raw string (no escaping). |
| void | jw_str (SYN_JsonWriter * w, const char * s) Write an escaped JSON string (with surrounding quotes). |
| void | jw_uint (SYN_JsonWriter * w, uint32_t val) Write an unsigned integer. |
Public Functions Documentation¶
function syn_json_arr_close¶
Close a JSON array ] .
Parameters:
wWriter.
function syn_json_arr_open¶
Open a JSON array [ .
Parameters:
wWriter.
function syn_json_init¶
Initialize a JSON writer.
Parameters:
wWriter instance.bufOutput buffer.capacityBuffer size in bytes.
function syn_json_key¶
Write a bare key "key": for nested objects/arrays.
Follow with syn_json_obj_open() or syn_json_arr_open().
Parameters:
wWriter.keyJSON key.
function syn_json_key_bool¶
Write "key":true or"key":false .
Parameters:
wWriter.keyJSON key.valBoolean value.
function syn_json_key_int¶
Write "key":123 .
Parameters:
wWriter.keyJSON key.valInteger value.
function syn_json_key_null¶
Write "key":null .
Parameters:
wWriter.keyJSON key.
function syn_json_key_str¶
Write "key":"value" . Escapes" and\\ in value.
Parameters:
wWriter.keyJSON key.valString value.
function syn_json_key_uint¶
Write "key":123 (unsigned).
Parameters:
wWriter.keyJSON key.valUnsigned integer value.
function syn_json_obj_close¶
Close a JSON object } .
Parameters:
wWriter.
function syn_json_obj_open¶
Open a JSON object { .
Parameters:
wWriter.
function syn_json_val_bool¶
Append a boolean value to an array.
Parameters:
wWriter.valBoolean value.
function syn_json_val_int¶
Append an integer value to an array.
Parameters:
wWriter.valInteger value.
function syn_json_val_str¶
Append a string value to an array.
Parameters:
wWriter.valString value.
function syn_json_val_uint¶
Append an unsigned integer value to an array.
Parameters:
wWriter.valUnsigned value.
Public Static Functions Documentation¶
function jw_comma¶
Insert comma separator if needed.
Parameters:
wJSON writer.
function jw_int¶
Write a signed integer.
Parameters:
wJSON writer.valValue to write.
function jw_putc¶
Append a single char to the output buffer.
Parameters:
wJSON writer.chCharacter to append.
function jw_puts¶
Append a raw string (no escaping).
Parameters:
wJSON writer.sString to append.
function jw_str¶
Write an escaped JSON string (with surrounding quotes).
Parameters:
wJSON writer.sString to encode.
function jw_uint¶
Write an unsigned integer.
Parameters:
wJSON writer.valValue to write.
The documentation for this class was generated from the following file src/syntropic/util/syn_json_write.c