How I can create Json Format in Qt ?
Unsolved
General and Desktop
-
I have an example, but not getting how I can create it.
{ "Version" : "1.0", "tap" : { }, "notation" : { }, "definition" : [ { "tag":1, "Name" : "view1" } { "tag":2, "Name" : "view2" } ] "images" : { "File" : "image.png", "Index" : 0, "Properties" : [ "black", "bold"] } }
Please give me an sample example which help me to create this.
-
@npatil15 Please take a look at https://doc.qt.io/qt-5/json.html first
You will even find a link to an example there... -
Hi
As a starter.
To build a json document, you insert the various json types that make up the structure.like
QJsonDocument doc; QJsonObject root; QJsonObject someObj; // create an array and put a double and object in it QJsonArray array; array.append( QJsonValue(32.4) ); array.append( someObj ); // add some properties to the root object root["intValue"] = 1; // add empty object root["SomeEmptyObject"] = someObj; //add the array root["somearray"] = array; // set to the document doc.setObject(root); qDebug().noquote().nospace() << doc.toJson();
{ "SomeEmptyObject":{ }, "intValue":1, "somearray":[ 32.4, { } ] }