|
Lite³
A JSON-Compatible Zero-Copy Serialization Format
|
Conversion between Lite³ and JSON. More...
Functions | |
| static int | lite3_ctx_json_dec (lite3_ctx *ctx, const char *__restrict json_str, size_t json_len) |
| Convert JSON string to Lite³ | |
| static int | lite3_ctx_json_dec_file (lite3_ctx *ctx, const char *__restrict path) |
| Convert JSON from file path to Lite³ | |
| static int | lite3_ctx_json_dec_fp (lite3_ctx *ctx, FILE *fp) |
| Convert JSON from file pointer to Lite³ | |
| static int | lite3_ctx_json_print (lite3_ctx *ctx, size_t ofs) |
Print Lite³ buffer as JSON to stdout | |
| static char * | lite3_ctx_json_enc (lite3_ctx *ctx, size_t ofs, size_t *__restrict out_len) |
| Convert Lite³ to JSON string. | |
| static char * | lite3_ctx_json_enc_pretty (lite3_ctx *ctx, size_t ofs, size_t *__restrict out_len) |
| Convert Lite³ to JSON prettified string. | |
| static int64_t | lite3_ctx_json_enc_buf (lite3_ctx *ctx, size_t ofs, char *__restrict json_buf, size_t json_bufsz) |
| Convert Lite³ to JSON and write to output buffer. | |
| static int64_t | lite3_ctx_json_enc_pretty_buf (lite3_ctx *ctx, size_t ofs, char *__restrict json_buf, size_t json_bufsz) |
| Convert Lite³ to prettified JSON and write to output buffer. | |
Conversion between Lite³ and JSON.
All JSON functionality is enabled internally by the yyjson library.
The ofs (offset) field is used to target an object or array inside the Lite³ buffer. To target the root-level object/array, use ofs == 0.
int64_t.double with correct rounding.int64_t, it is converted to double.double number overflows (reaches infinity), an error is returned.See: enum lite3_type
Makefile for more details. Also LITE3_JSON must be defined inside the lite3.h header or using compiler -D flags. See Library Configuration Options.
|
inlinestatic |
Convert JSON string to Lite³
malloc(). | [in] | ctx | context pointer |
| [in] | json_str | JSON input string (string) |
| [in] | json_len | JSON input string length (bytes, including or excluding NULL-terminator) |
Definition at line 2137 of file lite3_context_api.h.
|
inlinestatic |
Convert JSON from file path to Lite³
malloc(). | [in] | ctx | context pointer |
| [in] | path | JSON file path (string) |
Definition at line 2163 of file lite3_context_api.h.
|
inlinestatic |
Convert JSON from file pointer to Lite³
malloc(). | [in] | ctx | context pointer |
| [in] | fp | JSON file pointer |
Definition at line 2188 of file lite3_context_api.h.
|
inlinestatic |
Convert Lite³ to JSON string.
char * pointer to the JSON string on success NULL on errormalloc().LITE3_TYPE_BYTES are automatically converted to a base64 string.free() on the pointer returned by this function. | [in] | ctx | context pointer |
| [in] | ofs | start offset (0 == root) |
| [out] | out_len | string length excluding NULL-terminator (if not needed, pass NULL) |
Definition at line 2237 of file lite3_context_api.h.
|
inlinestatic |
Convert Lite³ to JSON and write to output buffer.
malloc().LITE3_TYPE_BYTES are automatically converted to a base64 string. | [in] | ctx | context pointer |
| [in] | ofs | start offset (0 == root) |
| [in] | json_buf | JSON output buffer |
| [in] | json_bufsz | JSON output buffer max size (bytes) |
Definition at line 2278 of file lite3_context_api.h.
|
inlinestatic |
Convert Lite³ to JSON prettified string.
The prettified string uses a tab space indent of 4.
char * pointer to the JSON string on success NULL on errormalloc().LITE3_TYPE_BYTES are automatically converted to a base64 string.free() on the pointer returned by this function. | [in] | ctx | context pointer |
| [in] | ofs | start offset (0 == root) |
| [out] | out_len | string length excluding NULL-terminator (if not needed, pass NULL) |
Definition at line 2260 of file lite3_context_api.h.
|
inlinestatic |
Convert Lite³ to prettified JSON and write to output buffer.
The prettified string uses a tab space indent of 4.
malloc().LITE3_TYPE_BYTES are automatically converted to a base64 string. | [in] | ctx | context pointer |
| [in] | ofs | start offset (0 == root) |
| [in] | json_buf | JSON output buffer |
| [in] | json_bufsz | JSON output buffer max size (bytes) |
Definition at line 2300 of file lite3_context_api.h.
|
inlinestatic |
Print Lite³ buffer as JSON to stdout
Very useful to make Lite³ structures human-readable inside a terminal. The ofs parameter can be used to selectively print an internal object or array. To print out the entire structure, call from the root using ofs == 0.
malloc().LITE3_TYPE_BYTES are automatically converted to a base64 string. | [in] | ctx | context pointer |
| [in] | ofs | start offset (0 == root) |
Definition at line 2217 of file lite3_context_api.h.