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

Function json_parse_object_context

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

Source from the content-addressed store, hash-verified

1166}
1167
1168static void json_parse_object_context(lua_State *l, json_parse_t *json)
1169{
1170 json_token_t token;
1171
1172 /* 3 slots required:
1173 * .., table, key, value */
1174 json_decode_descend(l, json, 3);
1175
1176 lua_newtable(l);
1177
1178 json_next_token(json, &token);
1179
1180 /* Handle empty objects */
1181 if (token.type == T_OBJ_END) {
1182 json_decode_ascend(json);
1183 return;
1184 }
1185
1186 while (1) {
1187 if (token.type != T_STRING)
1188 json_throw_parse_error(l, json, "object key string", &token);
1189
1190 /* Push key */
1191 lua_pushlstring(l, token.value.string, token.string_len);
1192
1193 json_next_token(json, &token);
1194 if (token.type != T_COLON)
1195 json_throw_parse_error(l, json, "colon", &token);
1196
1197 /* Fetch value */
1198 json_next_token(json, &token);
1199 json_process_value(l, json, &token);
1200
1201 /* Set key = value */
1202 lua_rawset(l, -3);
1203
1204 json_next_token(json, &token);
1205
1206 if (token.type == T_OBJ_END) {
1207 json_decode_ascend(json);
1208 return;
1209 }
1210
1211 if (token.type != T_COMMA)
1212 json_throw_parse_error(l, json, "comma or object end", &token);
1213
1214 json_next_token(json, &token);
1215 }
1216}
1217
1218/* Handle the array context */
1219static void json_parse_array_context(lua_State *l, json_parse_t *json)

Callers 1

json_process_valueFunction · 0.85

Calls 7

json_decode_descendFunction · 0.85
json_next_tokenFunction · 0.85
json_decode_ascendFunction · 0.85
json_throw_parse_errorFunction · 0.85
lua_pushlstringFunction · 0.85
json_process_valueFunction · 0.85
lua_rawsetFunction · 0.85

Tested by

no test coverage detected