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

Function Json_Decode

engine/script/src/script_json.cpp:132–143  ·  view source on GitHub ↗

decode JSON from a string to a lua-table * Decode a string of JSON data into a Lua table. * A Lua error is raised for syntax errors. * * @name json.decode * @param json [type:string] json data * @param [options] [type:table] table with decode options * * - [type:boolean] `decode_null_as_userdata`: whether to decode a JSON null value as json.null or nil (defa

Source from the content-addressed store, hash-verified

130 * ```
131 */
132 static int Json_Decode(lua_State* L)
133 {
134 int top = lua_gettop(L);
135 if (top == 0)
136 {
137 luaL_error(L, "json.decode requires one argument.");
138 }
139
140 size_t json_len;
141 const char* json = luaL_checklstring(L, 1, &json_len);
142 return JsonToLuaInternal(L, 2, json, json_len, 1);
143 }
144
145 /*# encode a lua table to a JSON string
146 * Encode a lua table to a JSON string.

Callers

nothing calls this directly

Calls 4

lua_gettopFunction · 0.85
luaL_errorFunction · 0.85
luaL_checklstringFunction · 0.85
JsonToLuaInternalFunction · 0.85

Tested by

no test coverage detected