Tarantool development patches archive
 help / color / mirror / Atom feed
* [tarantool-patches] [PATCH v1 1/1] app: fix parsing integers with exponent in json
@ 2018-07-10 10:42 Kirill Shcherbatov
  2018-07-10 12:14 ` [tarantool-patches] " Vladislav Shpilevoy
  0 siblings, 1 reply; 4+ messages in thread
From: Kirill Shcherbatov @ 2018-07-10 10:42 UTC (permalink / raw)
  To: tarantool-patches; +Cc: v.shpilevoy, Kirill Shcherbatov

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-07-10 15:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-10 10:42 [tarantool-patches] [PATCH v1 1/1] app: fix parsing integers with exponent in json Kirill Shcherbatov
2018-07-10 12:14 ` [tarantool-patches] " Vladislav Shpilevoy
2018-07-10 14:57   ` Kirill Shcherbatov
2018-07-10 15:14     ` Vladislav Shpilevoy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox