How I can create below Json Format in Qt ?
I have an example, but not getting how I can create it.
Code:
{
"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 a sample example which helps me to create this.
Re: How I can create below Json Format in Qt ?
I would say something like this
Code:
QJsonObject mainObject;
mainObject.insert("Version", "1.0");
mainObjecti.insert("tap", QJsonObject());
mainObjecti.insert("notation", QJsonObject());
QJsonObject definition1;
definition1.insert("tag", 1);
definition1.insert("Name", "view1");
QJsonObject definition2;
definition2.insert("tag", 2);
definition2.insert("Name", "view2");
QJsonArray definition;
defintion.append(definition1);
defintion.append(definition2);
mainObject.insert("definition", definition);
QJsonObject images;
images.insert("File", "image.png");
images.insert("Index", 0);
images.insert("Properties", QJsonArray{"black", "bold"});
mainObject.insert("images", images);
QJsonDocument document(mainObject);
QByteArray jsonData
= document.
toJson(QJsonDocument
::Indented);
Cheers,
_
Re: How I can create below Json Format in Qt ?