MCPcopy Create free account
hub / github.com/axmolengine/axmol / json_parse_array_context

Function json_parse_array_context

3rdparty/lua/lua-cjson/lua_cjson.c:1219–1254  ·  view source on GitHub ↗

Handle the array context */

Source from the content-addressed store, hash-verified

1217
1218/* Handle the array context */
1219static void json_parse_array_context(lua_State *l, json_parse_t *json)
1220{
1221 json_token_t token;
1222 int i;
1223
1224 /* 2 slots required:
1225 * .., table, value */
1226 json_decode_descend(l, json, 2);
1227
1228 lua_newtable(l);
1229
1230 json_next_token(json, &token);
1231
1232 /* Handle empty arrays */
1233 if (token.type == T_ARR_END) {
1234 json_decode_ascend(json);
1235 return;
1236 }
1237
1238 for (i = 1; ; i++) {
1239 json_process_value(l, json, &token);
1240 lua_rawseti(l, -2, i); /* arr[i] = value */
1241
1242 json_next_token(json, &token);
1243
1244 if (token.type == T_ARR_END) {
1245 json_decode_ascend(json);
1246 return;
1247 }
1248
1249 if (token.type != T_COMMA)
1250 json_throw_parse_error(l, json, "comma or array end", &token);
1251
1252 json_next_token(json, &token);
1253 }
1254}
1255
1256/* Handle the "value" context */
1257static void json_process_value(lua_State *l, json_parse_t *json,

Callers 1

json_process_valueFunction · 0.85

Calls 6

json_decode_descendFunction · 0.85
json_next_tokenFunction · 0.85
json_decode_ascendFunction · 0.85
json_process_valueFunction · 0.85
lua_rawsetiFunction · 0.85
json_throw_parse_errorFunction · 0.85

Tested by

no test coverage detected