5 static bool serialize_quoted_string(
JST_String *
string,
const char * s ) {
16 ||( ! serialize_quoted_string (
string, iter->name ))
21 JST_Error err = serialize_element( &(iter->element),
string, left_margin, indent );
33 for(
unsigned i = 0; i < array->
count; ++i ) {
49 static char buffer[100];
56 err = serialize_object( &(elt->
value.
object),
string, left_margin+indent, indent );
70 err = serialize_array( &(elt->
value.
array),
string, left_margin+indent, indent );
92 sprintf( buffer,
"%G", elt->
value.
dbl );
98 if( ! serialize_quoted_string(
string, elt->
value.
string )) {
113 if(( root == NULL )||( dest == NULL )) {
118 string.
buffer[
string.length] =
'\0';
119 *dest = realloc(
string.buffer,
string.length + 1 );
120 if( *dest == NULL ) {
124 string.buffer = NULL;
134 if( ( ! serialize_quoted_string(
string, iter->name ))
139 JST_Error err = serialize_element_compact( &(iter->element),
string );
153 for(
unsigned i = 0; i < array->
count; ++i ) {
158 if( i < array->count - 1 ) {
168 static char buffer[100];
170 switch( elt->
type ) {
175 err = serialize_object_compact( &(elt->
value.
object),
string );
187 err = serialize_array_compact( &(elt->
value.
array),
string );
207 sprintf( buffer,
"%G", elt->
value.
dbl );
213 if( ! serialize_quoted_string(
string, elt->
value.
string )) {
228 if(( root == NULL )||( dest == NULL )) {
232 if(( serialize_element_compact( root, &
string ) ==
JST_ERR_NONE )) {
233 string.
buffer[
string.length] =
'\0';
234 *dest = realloc(
string.buffer,
string.length + 1 );
235 if( *dest == NULL ) {
239 string.buffer = NULL;
bool JST_String_append_string(JST_String *string, const char *s)
A object attribute item has a parent and is a named-typed-value pair.
JST_Error JST_serialize_compact(JST_Element *root, char **dest)
Serialize the JSON tree to a string as a single line of text, without whitespaces.
A JSON object, a sorted set of named-value pairs.
struct JST_Pair_ * first
A linked list is mandatory to preserve the properties's order.
An element is a typed value.
bool JST_String_append_char(JST_String *string, char c)
JST_Error JST_String_delete(JST_String *string)
struct JST_Pair_ * next
A linked list is mandatory to preserve the properties's order.
bool JST_String_spaces(JST_String *string, unsigned count)
JST_Error JST_serialize(JST_Element *root, char **dest, unsigned indent)
Serialize the JSON tree to a string, pretty-printed.
struct JST_ArrayItem_ ** items
Array of JST_ArrayItem.
unsigned count
Cardinality of the previous array.
const JST_String JST_String_Zero