On terça-feira, 5 de novembro de 2013 11:44:41, Marc Mutz wrote:
> On Tuesday, November 05, 2013 01:07:32 Thiago Macieira wrote:
> > diff --git a/src/corelib/json/qjsonvalue.h b/src/corelib/json/qjsonvalue.h
> > index b8bdf55..c0ecdd2 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);
> >
> > @@ -102,6 +103,7 @@ public:
> > inline bool isUndefined() const { return type() == Undefined; }
> >
> > bool toBool(bool defaultValue = false) const;
> >
> > + int toInt(int defaultValue = 0) const;
> >
> > double toDouble(double defaultValue = 0) const;
> > QString toString(const QString &defaultValue = QString()) const;
> > QJsonArray toArray() const;
> >
> > @@ -157,6 +159,7 @@ public:
> > inline bool isUndefined() const { return type() ==
> >
> > QJsonValue::Undefined; }
> >
> > inline bool toBool() const { return toValue().toBool(); }
> >
> > + inline int toInt() const { return toValue().toInt(); }
> >
> > inline double toDouble() const { return toValue().toDouble(); }
> > inline QString toString() const { return toValue().toString(); }
> > QJsonArray toArray() const;
> >
> > @@ -176,7 +179,7 @@ private:
> > uint index : 31;
> >
> > };
>
> It seems there's no way to get the 64bit value back, once set with the new
> ctor.I think that was intentional since JSON is still using ECMAScript data types, whose Number type is a double precision floating point. Inserting any integer larger than 2^52 will result in loss of precision. So this forces people to use the toDouble() method to get the value back. > And isn't the new ctor going to be ambiguous? Not more than it is. Unless you're seeing something I'm not. Can you expand further? -- Thiago Macieira - thiago.macieira (AT) intel.com Software Architect - Intel Open Source Technology Center
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Development mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/development
