diff options
| author | ruki <[email protected]> | 2022-09-06 23:46:23 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-09-06 23:46:23 +0800 |
| commit | 35d62e7599db7d87b6071dc4b28392fc67311af3 (patch) | |
| tree | b932b6762e5beb1d95cbee30086e9bd2aaff23eb /xmake/core/base/json.lua | |
| parent | 400b22bf9ace156aa901d4aab8c46551f194ba50 (diff) | |
| parent | fa8e429ccae76cf1bb497a8c68e1ce1f162975ec (diff) | |
Merge pull request #2787 from xmake-io/cjson
Improve cjson to support empty array
Diffstat (limited to 'xmake/core/base/json.lua')
| -rw-r--r-- | xmake/core/base/json.lua | 14 |
1 files changed, 14 insertions, 0 deletions
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 |
