|
| | JsonWriter (char *buf, size_t cap) |
| | Construct over a caller buffer.
|
| |
| void | begin_object () |
| | Open { (as a value/element where applicable).
|
| |
| void | end_object () |
| | Close }.
|
| |
| void | begin_array () |
| | Open [.
|
| |
| void | end_array () |
| | Close ].
|
| |
| void | key (const char *k) |
| | Emit an object member name ("k":); follow with one value.
|
| |
| void | str (const char *v) |
| | Emit a quoted, escaped string value.
|
| |
| void | integer (long v) |
| | Emit a signed integer value.
|
| |
| void | uinteger (unsigned long v) |
| | Emit an unsigned integer value.
|
| |
| void | boolean (bool v) |
| | Emit true/false.
|
| |
| void | null_value () |
| | Emit null.
|
| |
| void | raw (const char *literal) |
| | Emit a pre-formatted literal verbatim.
|
| |
| void | kv_str (const char *k, const char *v) |
| | "k":"v" (escaped).
|
| |
| void | kv_int (const char *k, long v) |
| | "k":<int>.
|
| |
| void | kv_uint (const char *k, unsigned long v) |
| | "k":<uint>.
|
| |
| void | kv_bool (const char *k, bool v) |
| | "k":true|false.
|
| |
| void | kv_null (const char *k) |
| | "k":null.
|
| |
| void | kv_raw (const char *k, const char *literal) |
| | "k":<literal>.
|
| |
| bool | ok () const |
| | < False after any overflow / structural error.
|
| |
| size_t | length () const |
| | < Bytes written so far (excludes the NUL).
|
| |
| const char * | c_str () const |
| | < NUL-terminated output (truncated if !ok()).
|
| |
Builds a JSON document into a fixed caller buffer, no heap.
Commas, key quoting, and string escaping are emitted automatically. On buffer overflow or a structural error (nesting past JSON_MAX_DEPTH), writing stops and ok() returns false; c_str() still yields a NUL-terminated (truncated) string so a partial result never runs off the end.
Value methods (str(), integer(), ...) emit a single value - use them for array elements or immediately after key(). The kv_*() helpers emit a key and value together for object members.
Definition at line 58 of file json.h.