File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,12 @@ void print_json_object(const json_object_t *obj, int depth)
1313 int n = 0 ;
1414 int i ;
1515
16+ if (json_object_size (obj ) == 0 )
17+ {
18+ printf ("{}" );
19+ return ;
20+ }
21+
1622 printf ("{\n" );
1723 json_object_for_each (name , val , obj )
1824 {
@@ -37,6 +43,12 @@ void print_json_array(const json_array_t *arr, int depth)
3743 int n = 0 ;
3844 int i ;
3945
46+ if (json_array_size (arr ) == 0 )
47+ {
48+ printf ("[]" );
49+ return ;
50+ }
51+
4052 printf ("[\n" );
4153 json_array_for_each (val , arr )
4254 {
@@ -83,7 +95,10 @@ void print_json_string(const char *str)
8395 printf ("\\\\" );
8496 break ;
8597 default :
86- printf ("%c" , * str );
98+ if ((unsigned char )* str < 0x20 )
99+ printf ("\\u00%02x" , * str );
100+ else
101+ printf ("%c" , * str );
87102 break ;
88103 }
89104 str ++ ;
You can’t perform that action at this time.
0 commit comments