summaryrefslogtreecommitdiffstats
path: root/src/corelib/json
diff options
context:
space:
mode:
authorDarryl L. Miles <darryl.miles@darrylmiles.org>2013-02-13 17:25:15 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-12 22:33:23 +0200
commit5f9d58848a9e1a224dc5bf388e54d648e71ad259 (patch)
tree64e4fcfeecb23012f02a62bf69f339301356fc55 /src/corelib/json
parent6348de873724fc613446c46b5accfabab7afaaea (diff)
Json writer, support larger signed integers upto 2^53
Previously only 32bit signed integers were ensured to be supported by JsonValue type via API but it is expected that a larger integer range should be supported by a JSON implementation. This commit brings the Qt implementation into parity with NodeJS JSON.stringify() in respect of the JavaScript Number type. Change-Id: If91153cb3b13ecc14c50da97055b35ce42f341e7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/json')
-rw-r--r--src/corelib/json/qjsonvalue.cpp12
-rw-r--r--src/corelib/json/qjsonvalue.h1
2 files changed, 13 insertions, 0 deletions
diff --git a/src/corelib/json/qjsonvalue.cpp b/src/corelib/json/qjsonvalue.cpp
index a540626579..d0b06c6924 100644
--- a/src/corelib/json/qjsonvalue.cpp
+++ b/src/corelib/json/qjsonvalue.cpp
@@ -156,6 +156,18 @@ QJsonValue::QJsonValue(int n)
}
/*!
+ \overload
+ Creates a value of type Double, with value \a n.
+ NOTE: the integer limits for IEEE 754 double precision data is 2^53 (-9007199254740992 to +9007199254740992).
+ If you pass in values outside this range expect a loss of precision to occur.
+ */
+QJsonValue::QJsonValue(qint64 n)
+ : d(0), t(Double)
+{
+ this->dbl = n;
+}
+
+/*!
Creates a value of type String, with value \a s.
*/
QJsonValue::QJsonValue(const QString &s)
diff --git a/src/corelib/json/qjsonvalue.h b/src/corelib/json/qjsonvalue.h
index b8bdf55aa3..c8efab5d5f 100644
--- a/src/corelib/json/qjsonvalue.h
+++ b/src/corelib/json/qjsonvalue.h
@@ -79,6 +79,7 @@ public:
QJsonValue(bool b);
QJsonValue(double n);
QJsonValue(int n);
+ QJsonValue(qint64 n);
QJsonValue(const QString &s);
QJsonValue(QLatin1String s);
QJsonValue(const QJsonArray &a);