MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / parse_value

Function parse_value

lib/cJSON.c:1012–1057  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1010
1011/* Parser core - when encountering text, process appropriately. */
1012static const unsigned char *parse_value(cJSON *item, const unsigned char *value, const unsigned char **ep)
1013{
1014 if (!value)
1015 {
1016 /* Fail on null. */
1017 return NULL;
1018 }
1019
1020 /* parse the different types of values */
1021 if (!strncmp((const char*)value, "null", 4))
1022 {
1023 item->type = cJSON_NULL;
1024 return value + 4;
1025 }
1026 if (!strncmp((const char*)value, "false", 5))
1027 {
1028 item->type = cJSON_False;
1029 return value + 5;
1030 }
1031 if (!strncmp((const char*)value, "true", 4))
1032 {
1033 item->type = cJSON_True;
1034 item->valueint = 1;
1035 return value + 4;
1036 }
1037 if (*value == '\"')
1038 {
1039 return parse_string(item, value, ep);
1040 }
1041 if ((*value == '-') || ((*value >= '0') && (*value <= '9')))
1042 {
1043 return parse_number(item, value);
1044 }
1045 if (*value == '[')
1046 {
1047 return parse_array(item, value, ep);
1048 }
1049 if (*value == '{')
1050 {
1051 return parse_object(item, value, ep);
1052 }
1053
1054 /* failure. */
1055 *ep = value;
1056 return NULL;
1057}
1058
1059/* Render a value to text. */
1060static unsigned char *print_value(const cJSON *item, size_t depth, cjbool fmt, printbuffer *p)

Callers 3

cJSON_ParseWithOptsFunction · 0.70
parse_arrayFunction · 0.70
parse_objectFunction · 0.70

Calls 4

parse_stringFunction · 0.70
parse_numberFunction · 0.70
parse_arrayFunction · 0.70
parse_objectFunction · 0.70

Tested by

no test coverage detected