From: Kirill Shcherbatov <kshcherbatov@tarantool.org> To: tarantool-patches@freelists.org Cc: v.shpilevoy@tarantool.org, Kirill Shcherbatov <kshcherbatov@tarantool.org> Subject: [tarantool-patches] [PATCH v1 1/1] app: fix parsing integers with exponent in json Date: Tue, 10 Jul 2018 13:42:18 +0300 [thread overview] Message-ID: <d4f64e006b99c65b616a1092475bf02a7a767116.1531219214.git.kshcherbatov@tarantool.org> (raw) Now it is possible to specify a number in exponential form via all formats allowed by json standard. json.decode('{"remained_amount":2.0e+3}') json.decode('{"remained_amount":2.0E+3}') json.decode('{"remained_amount":2e+3}') json.decode('{"remained_amount":2E+3}') <-- fixed Closes #3514. --- https://github.com/tarantool/tarantool/issues/3514 https://github.com/tarantool/tarantool/commits/kshch/gh-3514-json-integers-with-exp test/app/json.result | 19 +++++++++++++++++++ test/app/json.test.lua | 6 ++++++ third_party/lua-cjson/lua_cjson.c | 2 +- 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 test/app/json.result create mode 100644 test/app/json.test.lua diff --git a/test/app/json.result b/test/app/json.result new file mode 100644 index 0000000..434e593 --- /dev/null +++ b/test/app/json.result @@ -0,0 +1,19 @@ +json = require('json') +--- +... +json.decode('{"remained_amount":2.0e+3}') +--- +- {'remained_amount': 2000} +... +json.decode('{"remained_amount":2.0E+3}') +--- +- {'remained_amount': 2000} +... +json.decode('{"remained_amount":2e+3}') +--- +- {'remained_amount': 2000} +... +json.decode('{"remained_amount":2E+3}') +--- +- {'remained_amount': 2000} +... diff --git a/test/app/json.test.lua b/test/app/json.test.lua new file mode 100644 index 0000000..b5485ca --- /dev/null +++ b/test/app/json.test.lua @@ -0,0 +1,6 @@ +json = require('json') + +json.decode('{"remained_amount":2.0e+3}') +json.decode('{"remained_amount":2.0E+3}') +json.decode('{"remained_amount":2e+3}') +json.decode('{"remained_amount":2E+3}') diff --git a/third_party/lua-cjson/lua_cjson.c b/third_party/lua-cjson/lua_cjson.c index aa8217d..11aa402 100644 --- a/third_party/lua-cjson/lua_cjson.c +++ b/third_party/lua-cjson/lua_cjson.c @@ -700,7 +700,7 @@ static void json_next_number_token(json_parse_t *json, json_token_t *token) token->type = T_UINT; token->value.ival = strtoull(json->ptr, &endptr, 10); } - if (*endptr == '.' || *endptr == 'e') { + if (*endptr == '.' || *endptr == 'e' || *endptr == 'E') { token->type = T_NUMBER; token->value.number = fpconv_strtod(json->ptr, &endptr); } -- 2.7.4
next reply other threads:[~2018-07-10 10:42 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-07-10 10:42 Kirill Shcherbatov [this message] 2018-07-10 12:14 ` [tarantool-patches] " Vladislav Shpilevoy 2018-07-10 14:57 ` Kirill Shcherbatov 2018-07-10 15:14 ` Vladislav Shpilevoy
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=d4f64e006b99c65b616a1092475bf02a7a767116.1531219214.git.kshcherbatov@tarantool.org \ --to=kshcherbatov@tarantool.org \ --cc=tarantool-patches@freelists.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [tarantool-patches] [PATCH v1 1/1] app: fix parsing integers with exponent in json' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox