Render a value to text. */
| 371 | |
| 372 | /* Render a value to text. */ |
| 373 | static char *print_value(cJSON *item,int depth,int fmt,printbuffer *p) |
| 374 | { |
| 375 | char *out=0; |
| 376 | if (!item) return 0; |
| 377 | if (p) |
| 378 | { |
| 379 | switch ((item->type)&255) |
| 380 | { |
| 381 | case cJSON_NULL: {out=ensure(p,5); if (out) strcpy(out,"null"); break;} |
| 382 | case cJSON_False: {out=ensure(p,6); if (out) strcpy(out,"false"); break;} |
| 383 | case cJSON_True: {out=ensure(p,5); if (out) strcpy(out,"true"); break;} |
| 384 | case cJSON_Number: out=print_number(item,p);break; |
| 385 | case cJSON_String: out=print_string(item,p);break; |
| 386 | case cJSON_Array: out=print_array(item,depth,fmt,p);break; |
| 387 | case cJSON_Object: out=print_object(item,depth,fmt,p);break; |
| 388 | } |
| 389 | } |
| 390 | else |
| 391 | { |
| 392 | switch ((item->type)&255) |
| 393 | { |
| 394 | case cJSON_NULL: out=cJSON_strdup("null"); break; |
| 395 | case cJSON_False: out=cJSON_strdup("false");break; |
| 396 | case cJSON_True: out=cJSON_strdup("true"); break; |
| 397 | case cJSON_Number: out=print_number(item,0);break; |
| 398 | case cJSON_String: out=print_string(item,0);break; |
| 399 | case cJSON_Array: out=print_array(item,depth,fmt,0);break; |
| 400 | case cJSON_Object: out=print_object(item,depth,fmt,0);break; |
| 401 | } |
| 402 | } |
| 403 | return out; |
| 404 | } |
| 405 | |
| 406 | /* Build an array from input text. */ |
| 407 | static const char *parse_array(cJSON *item,const char *value) |
no test coverage detected