MCPcopy Create free account
hub / github.com/9chu/LuaSTGPlus / json_process_value

Function json_process_value

LuaSTGPlus/LuaExtensions/cjson4lua/lua_cjson.c:1227–1254  ·  view source on GitHub ↗

Handle the "value" context */

Source from the content-addressed store, hash-verified

1225
1226/* Handle the "value" context */
1227static void json_process_value(lua_State *l, json_parse_t *json,
1228 json_token_t *token)
1229{
1230 switch (token->type) {
1231 case T_STRING:
1232 lua_pushlstring(l, token->value.string, token->string_len);
1233 break;;
1234 case T_NUMBER:
1235 lua_pushnumber(l, token->value.number);
1236 break;;
1237 case T_BOOLEAN:
1238 lua_pushboolean(l, token->value.boolean);
1239 break;;
1240 case T_OBJ_BEGIN:
1241 json_parse_object_context(l, json);
1242 break;;
1243 case T_ARR_BEGIN:
1244 json_parse_array_context(l, json);
1245 break;;
1246 case T_NULL:
1247 /* In Lua, setting "t[k] = nil" will delete k from the table.
1248 * Hence a NULL pointer lightuserdata object is used instead */
1249 lua_pushlightuserdata(l, NULL);
1250 break;;
1251 default:
1252 json_throw_parse_error(l, json, "value", token);
1253 }
1254}
1255
1256static int json_decode(lua_State *l)
1257{

Callers 3

json_parse_array_contextFunction · 0.85
json_decodeFunction · 0.85

Calls 3

json_parse_array_contextFunction · 0.85
json_throw_parse_errorFunction · 0.85

Tested by

no test coverage detected