Questions tagged [qjson]

QJson is a qt-based library that maps JSON data to QVariant objects: JSON arrays will be mapped to QVariantList instances, while JSON objects will be mapped to QVariantMap.

QJson is a small and easy-to-use library. Converting a JSON object is as simple as this:

// create a JSonDriver instance
QJson::Parser parser;
bool ok;

// json is a QString containing the data to convert
QVariant result = parser.parse (json, &ok);

Official page | API documentation

85 questions
1
vote
1 answer

Conversion methods for QJsonValue always return their default value

I am trying to convert QJsonValues into their correct data types, but the conversion always ends up returning their default value. For example, I have the following JSON object: { "val1": 99, "val2": true, "val3": "test" } I'm getting…
Endauriel
  • 402
  • 5
  • 17
1
vote
0 answers

Ubuntu: error while loading shared libraries: libqjsonrpc.so.1

I have downloaded the QJsonRpc (https://bitbucket.org/devonit/qjsonrpc/overview) and placed in the project directory in Ubuntu 14.04. While running the exe.file, it shows the following error: error while loading shared libraries: libqjsonrpc.so.1:…
Khizar Hameed
  • 41
  • 1
  • 7
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
2 answers

QJsonDocument::toJson() incorrect double precision

In my project I read from a json file with QJsonDocument::fromJson(). This works great, however when I try to write the QJsonDocument back to file with toJson() some of the doubles have messed up precision. For example, calling toJson() on a…
mrg95
  • 2,371
  • 11
  • 46
  • 89
1
vote
1 answer

Get QJsonObjects from QJsonarray without array name

i am new to QT and i have created a HTTP server, the server will run on windows and client on android, server will get POST request and response in JSON, something like that: Json response: [ { "FName": "fname", "LName":…
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

How to create a QJsonDocument?

I would like to create a QJsonDocument but I can't find a way to push my data in the document. At the end of JsonBuilder::CreateContact my document seem to be empty. Some help would be great please X). I've tried to use some pointer and add them to…
ShorKy
  • 77
  • 10
1
vote
1 answer

How to parse escape sequences in QString?

I have a QString that I need to insert it to a QJsonArray. The problem is that the string is inserrted as it is and the escape sequences doesnot work. QString fmt = QString("{\n \"%1\":\"%2\"\n}").arg(id,name); QJsonValue qjv(fmt); …
1
vote
1 answer

Using QjsonDocument to parse api data in QT

I have the below JSON which I am attempting to parse out. { "btc_usd": { "high": 245.304, "low": 240.10001, "avg": 242.702005, "vol": 1406884.29972, "vol_cur": 5776.14075, "last": 242.9, …
WeeniehuahuaXD
  • 852
  • 3
  • 10
  • 30
1
vote
0 answers

How can i Use QList as QT Meta object

Hi I am trying to convert the object into JSON. In that process i have created 2 classes. class class1 : Public object { Q_OBJECT Q_PROPERTY(QString Item1 READ getItem1 WRITE setItem1) Q_PROPERTY(qint64 Item2 READ getItem2 WRITE…
aditya
  • 21
  • 2
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
1
vote
2 answers

Qt - passing reference of QJsonObject or QJsonArray

I'm making Json format data editor with Qt treeview and Qt Json support. I wanna pass QJsonObject or QJsonArray reference parameter to function. This works: void makeJsonData(QJsonObject &obj) { obj.insert("key", 1234); } //call…
Winter Singha
  • 151
  • 1
  • 6
  • 16
1
vote
1 answer

no match for 'operator[]' (operand types are 'QVariant' and 'const char [2]') QVariant/QVariantMap

Im trying to make the start of a wrapper class for json in qt 5.1 and i'm working on a function which which will check if the var inputted is a QVariantMap or just a QVariant and everything works well till i go the second level of the muli dimen…
TheMan68
  • 1,429
  • 6
  • 26
  • 48