# HG changeset patch # User jbe # Date 1406917770 -7200 # Node ID 070edea2a92fa12eb108f499b9f4e596e3c8ddef # Parent f417c4b607ed2dae4254799fee4dba4187e233b4 Bugfix in json.object and json.array functions: use null-marker for nil values diff -r f417c4b607ed -r 070edea2a92f libraries/json/json.c --- a/libraries/json/json.c Fri Aug 01 18:52:25 2014 +0200 +++ b/libraries/json/json.c Fri Aug 01 20:29:30 2014 +0200 @@ -120,6 +120,8 @@ lua_pushvalue(L, json_convert_iterator_idx); lua_pushvalue(L, 1); lua_call(L, 1, 3); + // iterate through key value pairs and store them in shadow table + // while replacing nil values with null-marker: while (1) { lua_pushvalue(L, json_convert_iterfun_idx); lua_pushvalue(L, json_convert_itertbl_idx); @@ -129,7 +131,8 @@ if (lua_isnil(L, -2)) break; if (lua_type(L, -2) == (array ? LUA_TNUMBER : LUA_TSTRING)) { lua_pushvalue(L, -2); - lua_pushvalue(L, -2); + if (lua_isnil(L, -2)) json_pushnullmark(L); + else lua_pushvalue(L, -2); lua_rawset(L, json_convert_shadow_idx); } lua_pop(L, 1);