浏览代码

Merge pull request #8405 from afishbeck/jsonScientificNotation

HPCC-14928 Add support for parsing json scientific notation values

Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 9 年之前
父节点
当前提交
c3bf484f66
共有 1 个文件被更改,包括 15 次插入2 次删除
  1. 15 2
      system/jlib/jptree.cpp

+ 15 - 2
system/jlib/jptree.cpp

@@ -6407,11 +6407,24 @@ protected:
             if (!isdigit(nextChar))
                 error("Bad value");
             type = elementTypeInteger;
-            while (isdigit(nextChar) || '.'==nextChar)
+            bool exponent = false;
+            while (isdigit(nextChar) || '.'==nextChar || 'e'==nextChar || 'E'==nextChar)
             {
+                if ('e'==nextChar || 'E'==nextChar)
+                {
+                    if (exponent)
+                        error("Bad value");
+                    exponent=true;
+                    value.append(nextChar);
+                    readNext();
+                    if ('-'==nextChar)
+                        type=elementTypeReal;
+                    else if (!isdigit(nextChar) && '+'!=nextChar)
+                        error("Bad value");
+                }
                 if ('.'==nextChar)
                 {
-                    if (type==elementTypeReal) //already found decimal
+                    if (exponent || type==elementTypeReal) //already found decimal
                         error("Bad value");
                     type = elementTypeReal;
                 }