MCPcopy Create free account
hub / github.com/defold/defold / json_process_value

Function json_process_value

engine/script/src/luacjson/lua_cjson.c:1523–1560  ·  view source on GitHub ↗

Handle the "value" context */

Source from the content-addressed store, hash-verified

1521
1522/* Handle the "value" context */
1523static int json_process_value(lua_State *l, json_parse_t *json,
1524 json_token_t *token)
1525{
1526 switch (token->type) {
1527 case T_STRING:
1528 lua_pushlstring(l, token->value.string, token->string_len);
1529 break;;
1530 case T_NUMBER:
1531 lua_pushnumber(l, token->value.number);
1532 break;;
1533 case T_BOOLEAN:
1534 lua_pushboolean(l, token->value.boolean);
1535 break;;
1536 case T_OBJ_BEGIN:
1537 if (!json_parse_object_context(l, json))
1538 return 0;
1539 break;;
1540 case T_ARR_BEGIN:
1541 json_parse_array_context(l, json);
1542 break;;
1543 case T_NULL:
1544 /* In Lua, setting "t[k] = nil" will delete k from the table.
1545 * Hence a NULL pointer lightuserdata object is used instead */
1546 // DEFOLD:
1547 if (json->cfg->decode_null_as_userdata)
1548 {
1549 lua_pushlightuserdata(l, NULL);
1550 }
1551 else
1552 {
1553 lua_pushnil(l);
1554 }
1555 break;;
1556 default:
1557 return json_throw_parse_error(l, json, "value", token);
1558 }
1559 return 1;
1560}
1561
1562#if 0 // DEFOLD
1563static int json_decode(lua_State *l)

Callers 4

json_parse_array_contextFunction · 0.85
json_decodeFunction · 0.85
lua_cjson_decodeFunction · 0.85

Calls 8

lua_pushlstringFunction · 0.85
lua_pushnumberFunction · 0.85
lua_pushbooleanFunction · 0.85
json_parse_array_contextFunction · 0.85
lua_pushlightuserdataFunction · 0.85
lua_pushnilFunction · 0.85
json_throw_parse_errorFunction · 0.85

Tested by

no test coverage detected