Utilities & diagnostics¶
json_clone¶
Deep-copies a handle into a new one written to out_id. The copy is fully
independent — editing or freeing it never affects the source. Returns 1 on
success, 0 if the source is missing (E047). Free the clone when done.
new copy;
json_clone(doc, copy);
json_set_int(copy, "level", 99); // doc is untouched
json_free(copy);
json_merge¶
Deep-merges the src object into the dest object: nested objects are merged
key by key, any other value type overwrites. Both handles must be objects.
Merging a handle into itself is a no-op success. Returns 1 on success; 0 if a
side is missing (E047) or not an object (E058).
// dest = {"name":"Erick","level":1}, patch = {"level":50,"vip":true}
json_merge(dest, patch);
// dest -> {"name":"Erick","level":50,"vip":true}
json_clear¶
Empties an object/array handle in place, keeping the same id. Returns 1 on
success; 0 for a scalar (E057) or missing handle (E047).
json_equals¶
Structural deep comparison. Returns 1 when both handles exist and are deeply
equal, 0 otherwise.
json_count¶
Returns the number of handles currently open in the pool. Useful to catch leaks — call it before and after a block of work; the delta should return to baseline once everything is freed.
json_log¶
Sets the runtime log level. Always returns true.