mirror of
https://github.com/DaveGamble/cJSON.git
synced 2023-08-10 21:13:26 +03:00
Fix format problem with empty objects
When printing empty objects, the closing curly brace was missing one indentation level. Example from the output of test_utils: BEFORE FIX: { "foo": "bar", "child": { "grandchild": { } } } AFTER FIX: { "foo": "bar", "child": { "grandchild": { } } }
This commit is contained in:
parent
361b9a58cb
commit
9cc37a2844
2
cJSON.c
2
cJSON.c
@ -563,7 +563,7 @@ static char *print_object(cJSON *item,int depth,int fmt,printbuffer *p)
|
|||||||
else out=(char*)cJSON_malloc(fmt?depth+4:3);
|
else out=(char*)cJSON_malloc(fmt?depth+4:3);
|
||||||
if (!out) return 0;
|
if (!out) return 0;
|
||||||
ptr=out;*ptr++='{';
|
ptr=out;*ptr++='{';
|
||||||
if (fmt) {*ptr++='\n';for (i=0;i<depth-1;i++) *ptr++='\t';}
|
if (fmt) {*ptr++='\n';for (i=0;i<depth;i++) *ptr++='\t';}
|
||||||
*ptr++='}';*ptr++=0;
|
*ptr++='}';*ptr++=0;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user