Navigation

    Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    • Unsolved
    1. Home
    2. Tags
    3. qjsonobject
    Log in to post

    • UNSOLVED Write in JSON file - Data not inserted in the correct order
      General and Desktop • c++ json qjsonobject • • HW-Developer  

      14
      0
      Votes
      14
      Posts
      316
      Views

      I did resolve it using rapidjson instead of QJsonObject Thank you all
    • SOLVED Size limitation of QJsonObject at Qt 5.15
      General and Desktop • qjsonobject qjson • • MintogoDeveloper  

      3
      0
      Votes
      3
      Posts
      71
      Views

      @Christian-Ehrlicher Ok, thank you so much :)
    • UNSOLVED How to parse firebase GetUserData request's response?
      General and Desktop • qt6 qstring qjsonobject qjsondocument qjsonarray • • HeerokNewbie  

      6
      0
      Votes
      6
      Posts
      226
      Views

      @HeerokNewbie said in How to parse firebase GetUserData request's response?: Please correct this code 🙏 Too lazy to learn by yourself? "users" is an Array.
    • SOLVED Change a QJsonObject into an integer
      General and Desktop • gui json qjsonobject change integers • • hoonara  

      10
      0
      Votes
      10
      Posts
      3778
      Views

      @Christian-Ehrlicher ahh, you are right. Good catch. http://doc.qt.io/qt-5/qjsonvalue.html#toDouble converts the QJsonValue to double if its that type(). in this case it will return defaultValue (0) so its something like QJsonValue bid1 = jsonObj.value("bid_1"); QString asStr=bid1.toString(); double n = asStr.toDouble(); qDebug() << n;
    • SOLVED Key type of QJsonObject
      General and Desktop • json json parser qjsonobject • • tansgumus  

      5
      0
      Votes
      5
      Posts
      4401
      Views

      Thank you guys. What a wonderful quick responses.
    • SOLVED Json - access data in multidimensional arrays
      General and Desktop • qjsonobject qjsondocument qjsonarray qjsonvalue • • qDebug  

      9
      0
      Votes
      9
      Posts
      5828
      Views

      @JKSH Thank you! That did clear my mind! :D QJsonDocument to array, then foreach, next object value "site" toObject and now tadaaa object.value("name").toString; Great, thanks again!
    • SOLVED 'Garbage at the end of the document' error on parsing QJsonDocument
      General and Desktop • qtcpsocket serialization qjsonobject qjsondocument • • returnx  

      12
      0
      Votes
      12
      Posts
      8802
      Views

      @returnx Ok. super. please mark as solved :) Final note: When you deploy, there might be more reads for full json string. The code you shown, will try to parse on each read. Make sure the code can handle that it comes in blocks and not bail out if parse fails.
    • Parsing a QJsonObject from inside another QJsonObject
      General and Desktop • json json parser qjsonobject qjson parsing json • • LuisAbreu  

      2
      0
      Votes
      2
      Posts
      4439
      Views

      Hi @LuisAbreu! I cannot confirm this. Are you sure your json file is valid? The following works for me: ============================================ Json file: { "className": "ShoppingCart", "closedOn": "Fri Mar 27 15:52:13 2015", "coupon_count": "0", "createdOn": "Fri Mar 27 15:51:09 2015", "list": [ { "_className": "Product", "discount": "0", "fromyoubeep": "1", "has_alarm": 0, "id": "5601151333457", "intendedQuantity": 0, "isReady": "1", "isUnknown": "0", "loyaltyCredit": -1, "min_age": 0, "name": "Sumo Compal Cl<C3><A1>ssico Tutti-Fruti 1lt", "userCreated": "0", "weight": "0" }, { "_className": "Product", "fromyoubeep": "0", "has_alarm": 0, "id": "", "intendedQuantity": 0, "isReady": "1", "isUnknown": "0", "userCreated": "0", "weight": "0" } ], "loyaltyCard": { "_className": "LoyaltyCard", "barcode": "2446037038353", "barcodeType": "EAN13", "discount": "0", "fromyoubeep": "1", "has_alarm": 0, "id": "2446037038353", "intendedQuantity": 0, "isReady": "1", "isUnknown": "0", "loyaltyCredit": 0, "min_age": 0, "name": "Cart<C3><A3>o Poupa Mais", "price": "0", "product_id": "-1", "quantity": "0", "quantityValidated": "0", "state": "0", "type": 1, "userCreated": "0", "weight": "0" }, "mobile_checkout": "1" } ============================================ C++ code: QFile file("/home/pw/file.json"); if (!file.open(QIODevice::ReadOnly)) { qDebug() << "file error"; return; } const QByteArray ba = file.readAll(); file.close(); QJsonParseError err; QJsonDocument doc = QJsonDocument::fromJson(ba, &err); qDebug() << err.errorString(); qDebug() << err.offset; QJsonObject sett2 = doc.object(); qDebug() << sett2.isEmpty(); QJsonObject sett3 = sett2.value(QString("loyaltyCard")).toObject(); qDebug() << sett3.isEmpty(); QJsonValue sett4 = sett3.value(QString("barcode")); qDebug() << sett4.toString(); ============================================ Cheers!