Hello all,
I am running ina trouble, I need to work with int64 but I did not found a solution except to use they like strings.
In the following program the statement 'Doc.object()["ID"].toDouble();' return very close value but not exact, in my environment.
There is some way to extract the entire number without use the string form ("IDs":"635913899220803700") ?
#include <QtCore/QCoreApplication>
#include <QJsonDocument>
#include <QJsonParseError>
#include <QJsonObject>
int main(int argc, char *argv[]){
QString message
=R
"RR({"ID
":635913899220803700,"IDs
":"635913899220803700"})RR";
QJsonParseError err;
QJsonDocument Doc=QJsonDocument::fromJson(message.toUtf8(),&err);
unsigned long long ia=Doc.object()["ID"].toDouble();
unsigned long long ib=_atoi64(Doc.object()["IDs"].toString().toUtf8().data());
_ASSERT(ia==ib);
return a.exec();
}
#include <QtCore/QCoreApplication>
#include <QJsonDocument>
#include <QJsonParseError>
#include <QJsonObject>
int main(int argc, char *argv[]){
QCoreApplication a(argc, argv);
QString message=R"RR({"ID":635913899220803700,"IDs":"635913899220803700"})RR";
QJsonParseError err;
QJsonDocument Doc=QJsonDocument::fromJson(message.toUtf8(),&err);
unsigned long long ia=Doc.object()["ID"].toDouble();
unsigned long long ib=_atoi64(Doc.object()["IDs"].toString().toUtf8().data());
_ASSERT(ia==ib);
return a.exec();
}
To copy to clipboard, switch view to plain text mode
Cheers,
Giorgio
Bookmarks