# HG changeset patch # User jbe # Date 1406491357 -7200 # Node ID 3cafdf1143f3e21030ac69e4cd8d5ac3b0813287 # Parent dbe5881e4ecd38845fc84156ce8b4c51024c6579 Bugfix in json.type(...) function: Return nil if path is nonexistent, but return string "nil" if only last element is nil diff -r dbe5881e4ecd -r 3cafdf1143f3 libraries/json/json.c --- a/libraries/json/json.c Sun Jul 27 21:45:34 2014 +0200 +++ b/libraries/json/json.c Sun Jul 27 22:02:37 2014 +0200 @@ -219,6 +219,10 @@ argc = lua_gettop(L); lua_pushvalue(L, 1); while (idx <= argc) { + if (lua_isnil(L, -1)) { + if (mode == JSON_PATH_ISNULL) lua_pushboolean(L, 0); + return 1; + } lua_pushvalue(L, -1); lua_rawget(L, JSON_UPVAL_SHADOWTBL); if (lua_isnil(L, -1)) { @@ -234,10 +238,6 @@ lua_pushvalue(L, idx++); lua_rawget(L, -2); } - if (lua_isnil(L, -1)) { - if (mode == JSON_PATH_ISNULL) lua_pushboolean(L, 0); - return 1; - } lua_replace(L, -2); } switch (mode) {