MCPcopy Create free account
hub / github.com/MariaDB/server / json_get_array_item_int

Function json_get_array_item_int

strings/json_lib.c:2082–2118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2080}
2081
2082enum json_types json_get_array_item_int(json_engine_t *je, const char *js,
2083 const char *js_end, int n_item,
2084 const char **value, int *value_len)
2085{
2086 int c_item= 0;
2087
2088 json_scan_start(je, &my_charset_utf8mb4_bin,(const uchar *) js,
2089 (const uchar *) js_end);
2090
2091 if (json_read_value(je) ||
2092 je->value_type != JSON_VALUE_ARRAY)
2093 goto err_return;
2094
2095 while (!json_scan_next(je))
2096 {
2097 switch (je->state)
2098 {
2099 case JST_VALUE:
2100 if (c_item == n_item)
2101 return smart_read_value(je, value, value_len);
2102
2103 if (json_skip_key(je))
2104 goto err_return;
2105
2106 c_item++;
2107 break;
2108
2109 case JST_ARRAY_END:
2110 *value= (const char *) (je->s.c_str - je->sav_c_len);
2111 *value_len= c_item;
2112 return JSV_NOTHING;
2113 }
2114 }
2115
2116err_return:
2117 return JSV_BAD_JSON;
2118}
2119
2120enum json_types json_get_array_item(const char *js, const char *js_end, int n_item,
2121 const char **value, int *value_len)

Callers 1

json_get_array_itemFunction · 0.85

Calls 5

json_scan_startFunction · 0.85
json_read_valueFunction · 0.85
json_scan_nextFunction · 0.85
smart_read_valueFunction · 0.85
json_skip_keyFunction · 0.85

Tested by

no test coverage detected