# HG changeset patch # User jbe # Date 1406465060 -7200 # Node ID c507f8d62931c7b63a0155523f6234ac2ec9b821 # Parent 83aced09adc793540d98ffc42e54350f9546cd7e Make json.type return lua type if argument is not a JSON object or array diff -r 83aced09adc7 -r c507f8d62931 libraries/json/json.c --- a/libraries/json/json.c Sun Jul 27 14:38:00 2014 +0200 +++ b/libraries/json/json.c Sun Jul 27 14:44:20 2014 +0200 @@ -267,7 +267,9 @@ static int json_type(lua_State *L) { lua_settop(L, 1); + lua_pushvalue(L, 1); lua_rawget(L, JSON_UPVAL_TYPES); + if (lua_isnil(L, -1)) lua_pushstring(L, lua_typename(L, lua_type(L, 1))); return 1; }