Results 1 to 5 of 5

Thread: qjson int64 range

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2015
    Location
    Rome
    Posts
    16
    Thanks
    1
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Windows

    Default qjson int64 range

    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") ?




    Qt Code:
    1. #include <QtCore/QCoreApplication>
    2. #include <QJsonDocument>
    3. #include <QJsonParseError>
    4. #include <QJsonObject>
    5.  
    6. int main(int argc, char *argv[]){
    7. QCoreApplication a(argc, argv);
    8.  
    9. QString message=R"RR({"ID":635913899220803700,"IDs":"635913899220803700"})RR";
    10. QJsonParseError err;
    11.  
    12. QJsonDocument Doc=QJsonDocument::fromJson(message.toUtf8(),&err);
    13.  
    14. unsigned long long ia=Doc.object()["ID"].toDouble();
    15. unsigned long long ib=_atoi64(Doc.object()["IDs"].toString().toUtf8().data());
    16. _ASSERT(ia==ib);
    17.  
    18. return a.exec();
    19. }
    To copy to clipboard, switch view to plain text mode 


    Cheers,
    Giorgio
    Last edited by oop; 18th February 2016 at 16:29. Reason: updated contents

Similar Threads

  1. A problem about QJson
    By greatcl in forum Qt Programming
    Replies: 3
    Last Post: 14th May 2013, 10:20
  2. QJson
    By WetCode in forum Qt Programming
    Replies: 4
    Last Post: 20th February 2013, 22:54
  3. Qjson
    By Girija in forum Qt Programming
    Replies: 8
    Last Post: 17th September 2010, 14:19
  4. How to install Qjson in mac
    By Girija in forum Newbie
    Replies: 21
    Last Post: 17th September 2010, 09:55
  5. How to add a plugin? (QJson)
    By Thomas Wrobel in forum Newbie
    Replies: 5
    Last Post: 3rd December 2009, 21:46

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.