Parser core - when encountering text, process appropriately. */
| 365 | |
| 366 | /* Parser core - when encountering text, process appropriately. */ |
| 367 | static const char *parse_value(cJSON *item, const char *value) { |
| 368 | if (!value) return 0; /* Fail on null. */ |
| 369 | if (!strncmp(value, "null", 4)) { |
| 370 | item->type = cJSON_NULL; |
| 371 | return value + 4; |
| 372 | } |
| 373 | if (!strncmp(value, "false", 5)) { |
| 374 | item->type = cJSON_False; |
| 375 | return value + 5; |
| 376 | } |
| 377 | if (!strncmp(value, "true", 4)) { |
| 378 | item->type = cJSON_True; |
| 379 | item->valueint = 1; |
| 380 | return value + 4; |
| 381 | } |
| 382 | if (*value == '\"') { |
| 383 | return parse_string(item, value); |
| 384 | } |
| 385 | if (*value == '-' || (*value >= '0' && *value <= '9')) { |
| 386 | return parse_number(item, value); |
| 387 | } |
| 388 | if (*value == '[') { |
| 389 | return parse_array(item, value); |
| 390 | } |
| 391 | if (*value == '{') { |
| 392 | return parse_object(item, value); |
| 393 | } |
| 394 | |
| 395 | ep = value; |
| 396 | return 0; /* failure. */ |
| 397 | } |
| 398 | |
| 399 | /* Render a value to text. */ |
| 400 | static char *print_value(cJSON *item, int depth, int fmt) { |
no test coverage detected