From 2468e9a86a0575dfee193ff5f7b9e0c11e337077 Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 7 Sep 2022 00:49:59 +0800 Subject: update cjson --- core/src/lua-cjson/lua-cjson | 2 +- scripts/rpmbuild/SPECS/xmake.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/lua-cjson/lua-cjson b/core/src/lua-cjson/lua-cjson index 515bab6d6..ddcecf3b2 160000 --- a/core/src/lua-cjson/lua-cjson +++ b/core/src/lua-cjson/lua-cjson @@ -1 +1 @@ -Subproject commit 515bab6d6d80b164b94db73af69609ea02f3a798 +Subproject commit ddcecf3b24b71421e7b4a2962f1fbcc0297e0c1e diff --git a/scripts/rpmbuild/SPECS/xmake.spec b/scripts/rpmbuild/SPECS/xmake.spec index 9fc6ba594..14e2c0525 100644 --- a/scripts/rpmbuild/SPECS/xmake.spec +++ b/scripts/rpmbuild/SPECS/xmake.spec @@ -1,7 +1,7 @@ %define xmake_revision d1e9267d758ed360976bd4ef2eee3793f6ed7716 %define tbox_revision ac38b67ffe39d2bca5860a4bc91ec1f87cd71861 %define sv_revision 035262773da0500367cb88e6f30197908159a348 -%define lua_cjson_revision 515bab6d6d80b164b94db73af69609ea02f3a798 +%define lua_cjson_revision ddcecf3b24b71421e7b4a2962f1fbcc0297e0c1e %define luajit_revision e9af1abec542e6f9851ff2368e7f196b6382a44c %define lua_revision eadd8c7178c79c814ecca9652973a9b9dd4cc71b %define lz4_revision 033606ef259ef2852f6ae1e8ec7a10c641417654 -- cgit v1.3.1 From fa8e429ccae76cf1bb497a8c68e1ce1f162975ec Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 7 Sep 2022 00:51:12 +0800 Subject: improve json to support array --- xmake/core/base/json.lua | 14 ++++++++++++++ xmake/core/sandbox/modules/import/core/base/json.lua | 4 +++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/xmake/core/base/json.lua b/xmake/core/base/json.lua index 0b38df42a..e83f6b320 100644 --- a/xmake/core/base/json.lua +++ b/xmake/core/base/json.lua @@ -29,6 +29,20 @@ local utils = require("base/utils") -- export null json.null = cjson.null +-- support empty array +-- @see https://github.com/mpx/lua-cjson/issues/11 +function json.mark_as_array(luatable) + local mt = getmetatable(luatable) or {} + mt.__is_cjson_array = true + return setmetatable(luatable, mt) +end + +-- is marked as array? +function json.is_marked_as_array(luatable) + local mt = getmetatable(luatable) + return mt and mt.__is_cjson_array +end + -- decode json string to the lua table -- -- @param jsonstr the json string diff --git a/xmake/core/sandbox/modules/import/core/base/json.lua b/xmake/core/sandbox/modules/import/core/base/json.lua index 04073ca0d..ed551993d 100644 --- a/xmake/core/sandbox/modules/import/core/base/json.lua +++ b/xmake/core/sandbox/modules/import/core/base/json.lua @@ -26,7 +26,9 @@ local json = require("base/json") local raise = require("sandbox/modules/raise") -- inherit some builtin interfaces -sandbox_core_base_json.null = json.null +sandbox_core_base_json.null = json.null +sandbox_core_base_json.mark_as_array = json.mark_as_array +sandbox_core_base_json.is_marked_as_array = json.is_marked_as_array -- decode the json string to the lua table function sandbox_core_base_json.decode(jsonstr, opt) -- cgit v1.3.1