include/sig/value/sig_value_json.h
sig_status_t sig_value_to_json(const sig_value * v, char ** out, size_t * out_len)
| Parameter | Type |
|---|---|
v | const sig_value * |
out | char ** |
out_len | size_t * |
Serializes v as compact JSON. *out is a NUL-terminated heap string the caller must sig_free(); *out_len (nullable) excludes the NUL. Map keys are emitted in sorted (bytewise) order so output is deterministic. Non-finite doubles become null; bytes become a standard padded base64 string (one-way: parsing it back yields a string). Containers nested deeper than SIG_VALUE_MAX_DEPTH -> SIG_ERR_INVALID_ARG. *out is untouched on error.
sig_status_t sig_value_from_json(const char * text, size_t len, sig_value * out)
| Parameter | Type |
|---|---|
text | const char * |
len | size_t |
out | sig_value * |
Parses strict RFC 8259 JSON from text[0..len) (need not be NUL-terminated) into *out. Objects become maps (a duplicate key keeps the last value), arrays become lists, and a number with no fraction or exponent that fits sig_int_t becomes an int (any other number a double). \uXXXX escapes, including surrogate pairs, are decoded to UTF-8. Anything else -- trailing text, leading zeros, raw control characters in strings, null, NaN/Infinity, numbers that overflow a double, a NUL (\u0000) in an object key, nesting beyond SIG_VALUE_MAX_DEPTH -- is SIG_ERR_PARSE. SIG_ERR_ALLOC on allocation failure. *out is untouched on error and nothing leaks. The caller owns the result and must sig_value_dtor() it.