Render a value to text. */
| 398 | |
| 399 | /* Render a value to text. */ |
| 400 | static char *print_value(cJSON *item, int depth, int fmt) { |
| 401 | char *out = 0; |
| 402 | if (!item) return 0; |
| 403 | switch ((item->type) & 255) { |
| 404 | case cJSON_NULL: |
| 405 | out = cJSON_strdup("null"); |
| 406 | break; |
| 407 | case cJSON_False: |
| 408 | out = cJSON_strdup("false"); |
| 409 | break; |
| 410 | case cJSON_True: |
| 411 | out = cJSON_strdup("true"); |
| 412 | break; |
| 413 | case cJSON_Int: |
| 414 | out = print_int(item); |
| 415 | break; |
| 416 | case cJSON_Double: |
| 417 | out = print_double(item); |
| 418 | break; |
| 419 | case cJSON_String: |
| 420 | out = print_string(item); |
| 421 | break; |
| 422 | case cJSON_Array: |
| 423 | out = print_array(item, depth, fmt); |
| 424 | break; |
| 425 | case cJSON_Object: |
| 426 | out = print_object(item, depth, fmt); |
| 427 | break; |
| 428 | } |
| 429 | return out; |
| 430 | } |
| 431 | |
| 432 | /* Build an array from input text. */ |
| 433 | static const char *parse_array(cJSON *item, const char *value) { |
no test coverage detected