webmcp
changeset 132:3cafdf1143f3
Bugfix in json.type(...) function: Return nil if path is nonexistent, but return string "nil" if only last element is nil
author | jbe |
---|---|
date | Sun Jul 27 22:02:37 2014 +0200 (2014-07-27) |
parents | dbe5881e4ecd |
children | 214e11b72907 |
files | libraries/json/json.c |
line diff
1.1 --- a/libraries/json/json.c Sun Jul 27 21:45:34 2014 +0200 1.2 +++ b/libraries/json/json.c Sun Jul 27 22:02:37 2014 +0200 1.3 @@ -219,6 +219,10 @@ 1.4 argc = lua_gettop(L); 1.5 lua_pushvalue(L, 1); 1.6 while (idx <= argc) { 1.7 + if (lua_isnil(L, -1)) { 1.8 + if (mode == JSON_PATH_ISNULL) lua_pushboolean(L, 0); 1.9 + return 1; 1.10 + } 1.11 lua_pushvalue(L, -1); 1.12 lua_rawget(L, JSON_UPVAL_SHADOWTBL); 1.13 if (lua_isnil(L, -1)) { 1.14 @@ -234,10 +238,6 @@ 1.15 lua_pushvalue(L, idx++); 1.16 lua_rawget(L, -2); 1.17 } 1.18 - if (lua_isnil(L, -1)) { 1.19 - if (mode == JSON_PATH_ISNULL) lua_pushboolean(L, 0); 1.20 - return 1; 1.21 - } 1.22 lua_replace(L, -2); 1.23 } 1.24 switch (mode) {