C Collections

cjson · Section 3

cjson_serialize_pretty

cjson_serialize_pretty - serialize a DOM tree to an indented JSON string

C Collections (libccollections, -lccollections)

#include <ccollections/cjson.h>
 
char *cjson_serialize_pretty(cjson node, unsigned int indent);

Works like cjson_serialize(), but writes newlines and indents each
nesting level with spaces.  An indent of 0 selects the default of 4
spaces, so for compact output with no indent you use
cjson_serialize() instead.  Object members come out in the same
insertion order as with cjson_serialize(3).

A null-terminated string on the heap, from the root node's allocator.
Free it the same way as the result of cjson_serialize(3): With
cjson_serialize_free() when the tree uses the default allocator, and
with cjson_serialize_free_mp() when it uses a custom one.

cjson_dictionary_first(3), cjson_serialize(3)