diff options
author | Liang Qi <liang.qi@digia.com> | 2013-05-14 14:19:47 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-05-20 12:06:48 +0200 |
commit | 57acf1b46ca4bb670f4bf1fe3807dfa91edb6248 (patch) | |
tree | d2e2d02cb09fab9904ba9009c7b91fa5c1e375a1 /src | |
parent | abaaaea0416da2e111e543d67a31476b402cffde (diff) |
QtCore: fix the number precision in QJsonDocument.toJson()
In JSON, any number is stored in double. We need to make sure we
keep the maximum possible number precision for integer number. In
IEEE 754 double format, the significand precision is 53 bits(52
explicityly stored).
Autotest is included. qint64 and double work fine.
Task-number: QTBUG-28467
Change-Id: I7f857671c50e4334e9329c778f9b4f090f490540
Reviewed-by: Sune Vuorela <sune@vuorela.dk>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/json/qjsonwriter.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/json/qjsonwriter.cpp b/src/corelib/json/qjsonwriter.cpp index 76f62241e3..b09c6dd535 100644 --- a/src/corelib/json/qjsonwriter.cpp +++ b/src/corelib/json/qjsonwriter.cpp @@ -170,7 +170,7 @@ static void valueToJson(const QJsonPrivate::Base *b, const QJsonPrivate::Value & json += v.toBoolean() ? "true" : "false"; break; case QJsonValue::Double: - json += QByteArray::number(v.toDouble(b)); + json += QByteArray::number(v.toDouble(b), 'g', 13); break; case QJsonValue::String: json += '"'; |