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
1
vote
1 answer

Is there a way find a key in the whole json file using QJsonObject?

A key in any level of the json hierarchy, how can I find that key without knowing exact keys in the path?
sainimu78
  • 63
  • 6
1
vote
1 answer

QJsonObject how to create function

I know how to create members and values in a QJsonObject. What I want to do is create a Json function that when called will call the assigned function. Is this possible?
SPlatten
  • 5,334
  • 11
  • 57
  • 128
1
vote
1 answer

How I can add more than one QJsonObject to a QJsonDocument - Qt

I want to add more than one QJsonObject and not QJsonArray to a QJsonDocument. Is this possible? It should look like this: { "Obj1" : { "objID": "111", "C1" : { "Name":"Test1", "Enable" : true } …
AB Bolim
  • 1,997
  • 2
  • 23
  • 47
1
vote
1 answer

Qt Json Parsing c++

I am trying to parse json object in QT from an api. However when i try the codes written below i cannot parse the object. I simply want to get the information stored in those parameters. API is { "error": { "errorcode": 0, …
1
vote
1 answer

Converting JSON text file back to QJsonArray

I have an object that I serialize it into JSON using the code below (also see the the struct): struct RegisterItem { RegisterType Type = RegisterType::ReadWrite; QString Name = QStringLiteral("REGISTER"); int Bank = 0; int Address =…
DEKKER
  • 877
  • 6
  • 19
1
vote
1 answer

remove curly brackets from qjsonarray and replace square brackets from document

I'm inserting lot of different values to QJsonObjects like this: //gender inserted to QJsonObject gender QJsonObject gender; gender.insert("gender", person->gender()); //birthDate inserted to QJsonObject birthDate QJsonObject…
Lauri
  • 137
  • 1
  • 2
  • 8
1
vote
1 answer

QJsonValue gets empty

When I make request to the time API to get the Moscow time, I'm getting empty int in the variable. Here's the code: QNetworkReply* reply = manager->get(QNetworkRequest(QUrl("https://yandex.com/time/sync.json?geo=213"))); QEventLoop…
Joe Doe
  • 25
  • 1
  • 5
1
vote
1 answer

Get value from QJsonObject by index

In my app I use json object to get result from remote database. Usually response string looks like: { status:"ok", data: [ { field1:"value1", field2:"value2", field3:"value3" }, { field1:"value4", field2:"value5",…
folibis
  • 12,048
  • 6
  • 54
  • 97
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

Python Parse Oracle DDL and Generate JSON Data

I have a requirement where i need to parse a DDL from Oracle table and generate a JSON data out of it. For that i had used DDL parser in Python to convert it to string however i couldnt able to get it as JSON Data as such. import json from ddlparse…
Amdone
  • 5
  • 4
0
votes
0 answers

Inner Join Two List of Json Objects in Java

I want to join two json objects on the basis of their ids. List result1 = getRecordsFromDB1(); List result2 = getRecordsFromDB2(); result1 = [{"ID_COL":"Table1","DB1_TABLE_NAME":"Table1","DB1_COUNT":"10"},…
Sucheta
  • 13
  • 4
0
votes
1 answer

Extract elements from List of Strings and assign it to a separate String

I am new to Java and below is the requirement, I have a JSONArray like : [{"candidate_id":"agent_4","cluster_ID":"To_Be_Added","count":"2","utterance":"Can I text you a confirmation code on the line ending in 1544"},…
nikom
  • 71
  • 1
  • 1
  • 10
0
votes
0 answers

(org.json.simple.JSONObject and org.json.JSONObject are in unnamed module of loader 'app'

java.lang.ClassCastException: class org.json.simple.JSONObject cannot be cast to class org.json.JSONObject (org.json.simple.JSONObject and org.json.JSONObject are in unnamed module of loader 'app') hre the code expected to find name obj from json…
Aymen JBH
  • 1
  • 2
0
votes
1 answer

(Qt) Change value by key in QVariantMap nested in QVariantList (which is also nested in QVariantMap)

There is the following hierarchy: QVariantMap <- QVariantList <- QVariantMap The problem is QVariant::toList() and QVariant::toMap() return copies, which means I can't change value in a nested QVariantMap or QVariantList. Is there any way to solse…