summaryrefslogtreecommitdiffstats
path: root/src/corelib/json
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@theqtcompany.com>2015-11-10 15:41:01 +0100
committerUlf Hermann <ulf.hermann@theqtcompany.com>2015-11-23 14:13:48 +0000
commit573f87d81363a303b7005f999a283db624201db8 (patch)
tree0493995a00bba6df52f5322550d3005f597deb7e /src/corelib/json
parent15b5b3b3f01e400e46fe67babe593ede373dac4b (diff)
Use "shortest" double conversion for JSON
Task-number: QTBUG-42419 Change-Id: I649c4de96a2e41078e139c0f382e5a6cf96d3bb9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'src/corelib/json')
-rw-r--r--src/corelib/json/qjsonwriter.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/corelib/json/qjsonwriter.cpp b/src/corelib/json/qjsonwriter.cpp
index 45a05e93a3..0ab8b2bb80 100644
--- a/src/corelib/json/qjsonwriter.cpp
+++ b/src/corelib/json/qjsonwriter.cpp
@@ -32,6 +32,7 @@
**
****************************************************************************/
+#include <qlocale.h>
#include "qjsonwriter_p.h"
#include "qjson_p.h"
#include "private/qutfcodec_p.h"
@@ -123,7 +124,7 @@ static void valueToJson(const QJsonPrivate::Base *b, const QJsonPrivate::Value &
case QJsonValue::Double: {
const double d = v.toDouble(b);
if (qIsFinite(d)) // +2 to format to ensure the expected precision
- json += QByteArray::number(d, 'g', std::numeric_limits<double>::digits10 + 2); // ::digits10 is 15
+ json += QByteArray::number(d, 'g', QLocale::FloatingPointShortest);
else
json += "null"; // +INF || -INF || NaN (see RFC4627#section2.4)
break;