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
46
votes
3 answers

How to convert a QJsonObject to QString

I have a QJsonObject data and want to convert to QString. How can I do this? Searched for help in Qt, it only can convert QJsonObject to QVariantMap... Thanks in advance.
gogo000
  • 483
  • 1
  • 4
  • 8
5
votes
2 answers

is there a method to check if a QJsonObject object contains specific attribute?

there is a QJsonObject { "a":"...", "b":"...", "c":"..." } is there a method to check if this object contains "a"?
stamaimer
  • 6,227
  • 5
  • 34
  • 55
2
votes
0 answers

QJsonObject chained assignment produces unexpected results

When I assign the same value to two different non-existent keys in QJsonObject, I'm getting an unexpected result: json["first"] = json["second"] = "world!"; As far as I know, this code should add two new keys first and second, both with a value of…
rafalk42
  • 21
  • 2
2
votes
4 answers

How to merge two QJsonObjects in Qt?

I have: QJsonObject obj1({"bla" : "lab"}) QJsonObject obj2({"bla2" : "lab2"}) and I need: QJsonObject obj3({"bla" : "lab", "bla2" : "lab2"}) Or in JSON: { "bla" : "lab" } { "bla2" : "lab2" } And I need: { "bla" : "lab", "bla2" :…
dosvarog
  • 694
  • 1
  • 6
  • 20
2
votes
1 answer

JSON object Comparison in QT of same order and length

I have two objects which I wish to compare and display the differences of the values in the two objects. One is my reference object and another is my testing object. The order of the keys, the length of the objects are the same. The integer and…
RJ7
  • 33
  • 5
2
votes
1 answer

append QJsonObjects in a QJsonArray

I am trying to create a json file in which i insert QjsonObjects in an only one QJsonArray,what i get is every QjsonObject is in an independent QJsonArray but i want them to be in the same array. this function is called every time a save button is…
user user
  • 47
  • 1
  • 7
2
votes
2 answers

How to access element of JSON using Qt

I have this Json object and I want to access the "duration" and show it on console using Qt : { "kind": "youtube#videoListResponse", "etag": "\"cbz3lIQ2N25AfwNr-BdxUVxJ_QY/brZ0pmrmXldPPKpGPRM-8I4dDFQ\"", "pageInfo": { "totalResults": 1, …
Just_a_guy
  • 25
  • 1
  • 4
2
votes
1 answer

How send a QJsonObject using QWebChannel in Qt

Im implementing a HTML wrapper in Qt using QWebChannel, and im sucessifully able to send string, but, i woud like to send a QJsonObject, Not a json string like "{a:1,b:2}" but a Qt QJsonObject. Is it possible? the official documentation says "No…
Daniel Santos
  • 14,328
  • 21
  • 91
  • 174
2
votes
1 answer

How to generate JsonRpc request in qt?

I want to generate a qjsonstring in this format: {"id": 1, "params":{"parameter1": 1, "parameter2": 2}} But I don't know how to add parameter1 parameter2 to key params This is my code: QJsonObject *jsonObj = new QJsonObject();…
newww0
  • 181
  • 3
  • 12
2
votes
1 answer

QJsonDocument - getting values indented

I have a Json response like this: { "data": [ { "id": "someID", "participants": { "data": [ { "id": "idN1" }, { "id": "idN2" } ] } }, …
MuGiK
  • 351
  • 4
  • 13
1
vote
1 answer

I got exception while converting String to JSONObject

I am trying to consume restApi using volley. I am getting this Exception: org.json.JSONException: Value {"Emp_name":"Abc1","DOJ":"01-01-2021","DOB":"10-01-1997","Manager_name":"abc","designation":"TL"} of type java.lang.String cannot be converted to…
1
vote
2 answers

How to remove the "nameValuePairs" key from a json in java SpringBoot?

I have the following method that when receiving an xml in a String converts it to objects of type CitiMarketSSAEvent public CitiMarketSSAEvent convertXmlToObject(String xml){ CitiMarketSSAEvent citiMarket = null; JAXBContext jaxbContext…
Root93
  • 141
  • 8
1
vote
0 answers

How to add report title before header row in SheetJs in angular

I'm trying to export JSON to excel by using SheetJS, but I'm not able to add the title to the table. Now, I want to add a title in the middle of a row before the header row. In export service : import { Injectable } from '@angular/core'; import *…
Raveen
  • 13
  • 3
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
1 answer

Issue with inspecting QJsonObject in QtCreator with CDB

Recently updated to Qt 5.15.0. But now, I see some problems displaying JSON objects in the watchlist. Found nothing while digging google last few hours. See the screenshots: Any ideas what is wrong with the settings ? Or debug helpers ? Or it is…
smacker
  • 151
  • 6
1
2 3 4