mirror of
https://github.com/coolsnowwolf/luci.git
synced 2025-05-02 17:10:27 +08:00
Update jsonc.c (#23)
This commit is contained in:
parent
a6189c5e29
commit
b2cf61d0a0
@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <json-c/json.h>
|
#include <json-c/json.h>
|
||||||
|
|
||||||
@ -138,6 +139,7 @@ static int json_parse_chunk(lua_State *L)
|
|||||||
|
|
||||||
static void _json_to_lua(lua_State *L, struct json_object *obj)
|
static void _json_to_lua(lua_State *L, struct json_object *obj)
|
||||||
{
|
{
|
||||||
|
int64_t v;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
switch (json_object_get_type(obj))
|
switch (json_object_get_type(obj))
|
||||||
@ -165,7 +167,12 @@ static void _json_to_lua(lua_State *L, struct json_object *obj)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case json_type_int:
|
case json_type_int:
|
||||||
lua_pushinteger(L, json_object_get_int(obj));
|
v = json_object_get_int64(obj);
|
||||||
|
if (sizeof(lua_Integer) > sizeof(int32_t) ||
|
||||||
|
(v >= INT32_MIN && v <= INT32_MAX))
|
||||||
|
lua_pushinteger(L, (lua_Integer)v);
|
||||||
|
else
|
||||||
|
lua_pushnumber(L, (lua_Number)v);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case json_type_double:
|
case json_type_double:
|
||||||
|
Loading…
Reference in New Issue
Block a user