MCPcopy Create free account
hub / github.com/Tencent/TAD_Sim / parse_value

Function parse_value

common/map_sdk/transmission/src/cJSON.cpp:367–397  ·  view source on GitHub ↗

Parser core - when encountering text, process appropriately. */

Source from the content-addressed store, hash-verified

365
366/* Parser core - when encountering text, process appropriately. */
367static 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. */
400static char *print_value(cJSON *item, int depth, int fmt) {

Callers 3

cJSON_ParseFunction · 0.85
parse_arrayFunction · 0.85
parse_objectFunction · 0.85

Calls 4

parse_stringFunction · 0.85
parse_numberFunction · 0.85
parse_arrayFunction · 0.85
parse_objectFunction · 0.85

Tested by

no test coverage detected