Render a value to text. */
| 501 | |
| 502 | /* Render a value to text. */ |
| 503 | static char *print_value(cJSON *item, int depth, int fmt) |
| 504 | { |
| 505 | char *out = 0; |
| 506 | if (!item) |
| 507 | return 0; |
| 508 | switch ((item->type) & 255) |
| 509 | { |
| 510 | case cJSON_NULL: |
| 511 | out = cJSON_strdup("null"); |
| 512 | break; |
| 513 | case cJSON_False: |
| 514 | out = cJSON_strdup("false"); |
| 515 | break; |
| 516 | case cJSON_True: |
| 517 | out = cJSON_strdup("true"); |
| 518 | break; |
| 519 | case cJSON_Int: |
| 520 | out = print_int(item); |
| 521 | break; |
| 522 | case cJSON_Double: |
| 523 | out = print_double(item); |
| 524 | break; |
| 525 | case cJSON_String: |
| 526 | out = print_string(item); |
| 527 | break; |
| 528 | case cJSON_Array: |
| 529 | out = print_array(item, depth, fmt); |
| 530 | break; |
| 531 | case cJSON_Object: |
| 532 | out = print_object(item, depth, fmt); |
| 533 | break; |
| 534 | } |
| 535 | return out; |
| 536 | } |
| 537 | |
| 538 | /* Build an array from input text. */ |
| 539 | static const char *parse_array(cJSON *item, const char *value, const char **ep) |
no test coverage detected