webmcp
changeset 128:c507f8d62931
Make json.type return lua type if argument is not a JSON object or array
author | jbe |
---|---|
date | Sun Jul 27 14:44:20 2014 +0200 (2014-07-27) |
parents | 83aced09adc7 |
children | 453d8f8fbace |
files | libraries/json/json.c |
line diff
1.1 --- a/libraries/json/json.c Sun Jul 27 14:38:00 2014 +0200 1.2 +++ b/libraries/json/json.c Sun Jul 27 14:44:20 2014 +0200 1.3 @@ -267,7 +267,9 @@ 1.4 1.5 static int json_type(lua_State *L) { 1.6 lua_settop(L, 1); 1.7 + lua_pushvalue(L, 1); 1.8 lua_rawget(L, JSON_UPVAL_TYPES); 1.9 + if (lua_isnil(L, -1)) lua_pushstring(L, lua_typename(L, lua_type(L, 1))); 1.10 return 1; 1.11 } 1.12