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
| 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. |
nothing calls this directly
no test coverage detected