QJsonObject create nested Object
Unsolved
General and Desktop
-
Hello,
I want to generate a nested Json Object to transmit via QWebsocket.
I could not find any documentation or example about how to create a nested object like:{ name: "name", type: "randomtype", children: [{ name: "child1", type: "randomtype"}, {name: "child2", type: "randomtype"}] }
Is it possible to do this somehow in the normal QJsonObject notation like:
QJsonObject json { {"type", "textMessage"}, {"from", fromID}, {"to",toID}, {"time", QTime::currentTime().toString("hh:mm:ss")}, {"name", fromName}, {"line", message}, {"mode", targetMode} };
-
Hi and welcome to the forums.
Do you mean a JSON array ? ( by nested)
LikeQJsonArray array; QJsonObject Obj { {"xxx", "yyyy"} }; array.append( Obj ); QJsonObject json { {"type", "textMessage"}, {"Array", array} };