From 6e4e29d73694ac4da0308e5b3af779799fd32f63 Mon Sep 17 00:00:00 2001 From: xiehan <52160700+Barenboim@users.noreply.github.com> Date: Mon, 18 Dec 2023 19:16:29 +0800 Subject: [PATCH] Parse JSON number consistently. (#1451) --- src/util/json_parser.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/util/json_parser.c b/src/util/json_parser.c index 9b379c86..65e9cba0 100644 --- a/src/util/json_parser.c +++ b/src/util/json_parser.c @@ -363,6 +363,23 @@ static double __evaluate_json_number(const char *integer, figures++; } + if (exp != 0 && figures != 0) + { + while (exp > 0 && figures < 18) + { + mant *= 10; + exp--; + figures++; + } + + while (exp < 0 && mant % 10 == 0) + { + mant /= 10; + exp++; + figures--; + } + } + num = mant; if (exp != 0 && figures != 0) {