Questions tagged [qjsonobject]

The QJsonObject class encapsulates a JSON object, where the keys are unique strings and the values are represented by a QJsonValue.

Description

The QJsonObject class encapsulates a JSON object.

A JSON object is a list of key value pairs, where the keys are unique strings and the values are represented by a QJsonValue.

A QJsonObject can be converted to and from a QVariantMap. You can query the number of (key, value) pairs with size(), insert(), and remove() entries from it and iterate over its content using the standard C++ iterator pattern.

QJsonObject is an implicitly shared class, and shares the data with the document it has been created from as long as it is not being modified.

You can convert the object to and from text based JSON through QJsonDocument.

Link

qt-project

47 questions
0
votes
1 answer

How to convert from QString to JSON in C++ side

In qml, templist: [{"product_code":"111111111","product_name":"AAAA"}, {"product_code":"222222222","product_name":"BBBB"}, {"product_code":"33333333","product_name":"CCCC"}] with the help of below code in the qml side, the above templist sent to…
0
votes
1 answer

how to update jsonobject in an array from two different json arrays having same keys

I have two json array one that is named http and another is websocketjsonArray , so there is one condition i haveto followup is inside nested for loop is that if their scripcode and userid is same then put and update data from websocketjsonarray…
Abhishek
  • 25
  • 3
0
votes
1 answer

Vertx how can I get the body of a request

I want to get the body of a request. This request is HttpRequest. I'm using vertx. I try to get the body making a new webclient or I can use the existing routingcontext. (1)I don't know how to call the api with routing context. (2)I'm using an…
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
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

Update value in QJsonArray and write back to Json file in Qt

I have a Json file to read and display on UI. Reading is fine but when I tried to update value wheelbase, code runs with no errors but it does not update the Json Json file example { "$type": "SystemList", "$values": [ { …
Neung Chung
  • 159
  • 1
  • 1
  • 10
0
votes
1 answer

Modifying an QJsonArray within a QJsonObject?

How to modify an array which is already inside a QJsonObject structure? QJsonObject data = QJsonDocument::fromJson(QByteArrayLiteral("{\"array\":[1,2,3]}")).object(); // TODO: Something to append numbers to the 1,2,3 array? // This doesn't work:…
OJW
  • 4,514
  • 6
  • 40
  • 48
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

How to parse this JSON file? (Qt)

Im using Qt5.7.1 and trying to read information in my JSON file. The structure of my file includes: the name of the configuration, the number of neurons, an array of neurons (each neuron has a strict number of receptors and synapses, which are also…
0
votes
1 answer

Is there possible to convert QVector into Json string?

I have struct type: struct Book { int id; QString name; QString author; } And I read these from JSON text, and store them to QVector container. How to convert this vector back to JSON text?
0
votes
1 answer

Does QJsonValue differ strings of digits from integers?

When I parse json, is there any way to distinct this situations: my_value = "123" and my_value = 123 ?
ephemerr
  • 1,833
  • 19
  • 22
0
votes
1 answer

QJsonObject partial path from variable

I have a json object that I load: QJsonObject json = CommonToolkit::Types::LoadJson(config); Here is a partial of the json file content: { "config": { "macos": { "screen": { "main": { "height": 0, …
adviner
  • 3,295
  • 10
  • 35
  • 64
0
votes
1 answer

How to modify QJsonObject

I can set values to objects this way in the simple json-file. Qt code: if(file.open(QIODevice::ReadOnly)){ QJsonDocument doc = QJsonDocument::fromJson(file.readAll()); QJsonObject obj = doc.object(); obj["gender"] = "female"; …
Lauri
  • 137
  • 1
  • 2
  • 8
0
votes
1 answer

Delete a child attribute from json file

I have the following HTTP JSON-response in Java, which represents a user object. { "account": "Kpatrick", "firstname": "Patrick", [ ], "instances": [ { "id": "packerer-pool", "key":…
InfoEngi
  • 303
  • 1
  • 10
  • 23
0
votes
1 answer

error: C2039: 'pointer' : is not a member of 'QJsonObject::iterator'

I'm having a weird error when trying to use 'QJsonObject::iterator' with MSVC2013. I have the following example: #include #include #include #include void processValue(QJsonValue value) { …
AntonyG
  • 861
  • 9
  • 22