Questions tagged [qjsondocument]

8 questions
1
vote
1 answer

Cannot convert std::string to QJsonArray in Qt

The following text is a bit of std::string text that is generated by another app (I do not have control of what the app sends me). I have tried for days to get this converted into a QJsonArray and cannot figure this out. I am using C++ within QT. …
1
vote
0 answers

How to preserve zeros at end of doubles in QJsonDocument?

I'm reading, parsing and writing back a JSON file in a QT project. Part of the requirements is that all entry's should be the same written out as declared in the source file. One of the entries looks somewhat like this: "SomeVal":…
Mathlight
  • 6,436
  • 17
  • 62
  • 107
0
votes
1 answer

Flatten multidimensional nested Qt Json structure like QJsonValue / QJsonObject / QJsonArray

Seeking a way of flattening a multidimensional nested QJsonValue containing all 6 basic data types (object, array, bool, double, String, Null). Simple example for the purpose of understanding...Input: { "date": 1681693886, "online": true, …
marc
  • 1,207
  • 11
  • 16
0
votes
0 answers

Save New line in JSON file in QT

I have a QString eg: QString test = "Hello"; test += "\n"; test += "World"; I am saving this in a file : QFile file("test.json"); if (!file.open(QIODevice::WriteOnly )) return; jsonObj = QJsonObject() jsonObj.insert("Key",test); QJsonDocument…
HARSH MITTAL
  • 750
  • 4
  • 17
0
votes
1 answer

Indexing unnamed QJsonDocument in Qt < 5.10

Given unnamed JSON document: [ { }, { }, ] Qt 5.10+ has operator[] for QJsonDocument, so we can address any of them by index: json_doc[1]; How does one do the same in older versions of Qt?
Amanda Helgström
  • 115
  • 1
  • 1
  • 8
0
votes
2 answers

Write in JSON file - Data not inserted in the correct order

I am creating a desktop app using QT C++ that take a text file and convert it to JSON File like this example: { "102": { "NEUTRAL": { "blend": "100" }, "AE": { "blend": "100" } }, …
it4Astuces
  • 432
  • 5
  • 17
0
votes
1 answer

QJsonDocument to object is empty

I'm trying to parse a simple JSON data in Qt5. Code looks like this : ... socket->readDatagram(Buffer.data(),Buffer.size(),&sender,&senderPort); QJsonParseError jsonError; QJsonDocument dataJson =…
Maifee Ul Asad
  • 3,992
  • 6
  • 38
  • 86
0
votes
1 answer

QJsonDocument fails with a confusing error

Consider the following piece of code: from PyQt5.QtCore import QJsonDocument json = { "catalog": [ { "version": None, }, ] } QJsonDocument(json) Under Python 3.7 and PyQt 5.14.2, it results in the following…
StSav012
  • 776
  • 5
  • 15