diff options
| author | ruki <[email protected]> | 2024-07-02 23:41:06 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-07-02 23:41:06 +0800 |
| commit | 6289723f9bd7dbc44bdcfa32ad4fe9bece0e3840 (patch) | |
| tree | 487f0f2d36bdb1a8b4b074e15ef06d9119622483 /xmake/core/base/json.lua | |
| parent | 35ec8577f2d81e472a8bc0db9ce66215f3182b4f (diff) | |
add hex support for pure json
Diffstat (limited to 'xmake/core/base/json.lua')
| -rw-r--r-- | xmake/core/base/json.lua | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/xmake/core/base/json.lua b/xmake/core/base/json.lua index bf1dfae3e..487e4b062 100644 --- a/xmake/core/base/json.lua +++ b/xmake/core/base/json.lua @@ -26,6 +26,8 @@ local io = require("base/io") local os = require("base/os") local utils = require("base/utils") +cjson = nil + -- export null if cjson then json.null = cjson.null @@ -116,7 +118,12 @@ function json._pure_parse_str_val(str, pos, val) end function json._pure_parse_num_val(str, pos) - local num_str = str:match('^-?%d+%.?%d*[eE]?[+-]?%d*', pos) + local num_str + if str:sub(pos, pos + 1) == "0x" then + num_str = str:match('^-?0[xX][0-9a-fA-F]+', pos) + else + num_str = str:match('^-?%d+%.?%d*[eE]?[+-]?%d*', pos) + end local val = tonumber(num_str) if not val then os.raise("error parsing number at position %d", pos) |
