<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to Create dynamically JSON object in QT ?]]></title><description><![CDATA[<p dir="auto">I need to insert the value in that JSON object.</p>
<p dir="auto">give some reference link or documents so i will create dynamically JSON object in my qt creator.</p>
]]></description><link>https://forum.qt.io/topic/87798/how-to-create-dynamically-json-object-in-qt</link><generator>RSS for Node</generator><lastBuildDate>Sun, 14 Jun 2026 03:59:11 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/87798.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 15 Feb 2018 07:47:09 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to Create dynamically JSON object in QT ? on Fri, 16 Feb 2018 13:35:02 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mayank-thakor">@<bdi>Mayank-Thakor</bdi></a> if your issue is finally solved, please don't forget to mark your post as such! thank you.</p>
]]></description><link>https://forum.qt.io/post/442459</link><guid isPermaLink="true">https://forum.qt.io/post/442459</guid><dc:creator><![CDATA[Pablo J. Rogina]]></dc:creator><pubDate>Fri, 16 Feb 2018 13:35:02 GMT</pubDate></item><item><title><![CDATA[Reply to How to Create dynamically JSON object in QT ? on Fri, 16 Feb 2018 05:56:41 GMT]]></title><description><![CDATA[<p dir="auto">@LeLev said in <a href="/post/442337">How to Create dynamically JSON object in QT ?</a>:</p>
<blockquote>
<p dir="auto">QStringList</p>
</blockquote>
<p dir="auto">Okay got it</p>
<p dir="auto">Thank you !</p>
]]></description><link>https://forum.qt.io/post/442388</link><guid isPermaLink="true">https://forum.qt.io/post/442388</guid><dc:creator><![CDATA[Mayank Thakor]]></dc:creator><pubDate>Fri, 16 Feb 2018 05:56:41 GMT</pubDate></item><item><title><![CDATA[Reply to How to Create dynamically JSON object in QT ? on Thu, 15 Feb 2018 17:22:17 GMT]]></title><description><![CDATA[<p dir="auto">hi <a class="plugin-mentions-user plugin-mentions-a" href="/user/mayank-thakor">@<bdi>Mayank-Thakor</bdi></a>,</p>
<p dir="auto">Im not sure but, would it be possible to insert your 'TYPE ' and 'property ' directly in the json obj itself ?</p>
<pre><code>QJsonObject obj;
obj.insert("TYPE", "jason_type_1"); // type
obj.insert("prop1", jason_1_property_1); // property 1
obj.insert("prop1", jason_1_property_2); // property 2
obj.insert("array", QStringList() {"a", "b"});
QJsonDocument doc(obj).toJson(); // &lt;- this is your JSON string
</code></pre>
<p dir="auto"><em>Edit : also look this  <a href="http://doc.qt.io/qt-5/qtqml-javascript-dynamicobjectcreation.html" target="_blank" rel="noopener noreferrer nofollow ugc">http://doc.qt.io/qt-5/qtqml-javascript-dynamicobjectcreation.html</a></em></p>
]]></description><link>https://forum.qt.io/post/442337</link><guid isPermaLink="true">https://forum.qt.io/post/442337</guid><dc:creator><![CDATA[ODБOï]]></dc:creator><pubDate>Thu, 15 Feb 2018 17:22:17 GMT</pubDate></item><item><title><![CDATA[Reply to How to Create dynamically JSON object in QT ? on Thu, 15 Feb 2018 13:05:28 GMT]]></title><description><![CDATA[<p dir="auto">THANK YOU<br />
i want like this and i understand this</p>
<p dir="auto">QJsonObject obj;<br />
obj.insert("someKey", "someValue");<br />
obj.insert("someOtherKey", 123);<br />
obj.insert("array", QStringList() {"a", "b"});<br />
QJsonDocument doc(obj).toJson(); // &lt;- this is your JSON string</p>
<p dir="auto">but</p>
<p dir="auto">I want to create JSON object dynamically (with new ) and i want to give TYPE and other property.</p>
<p dir="auto">for example<br />
one jason message it's TYPE is "jason_type_1" and it has 2 property like "jason_1_property_1" and "jason_property_2".</p>
<p dir="auto">second jason message it's TYPE is "jason_type_2" and it has 3 property like "jason_2_property_1" , "jason_2_property_2" and "jason_3_property_3".</p>
<p dir="auto">so base on the TYPE "jason_type_1" or "jason_type_2" i can filter the message and<br />
then i read property like<br />
QString read_string = (jsonObj["body"].toObject()["jason_1_property_1"]).toString();</p>
<p dir="auto">so can you please give example how i will create this in QT ?</p>
]]></description><link>https://forum.qt.io/post/442293</link><guid isPermaLink="true">https://forum.qt.io/post/442293</guid><dc:creator><![CDATA[Mayank Thakor]]></dc:creator><pubDate>Thu, 15 Feb 2018 13:05:28 GMT</pubDate></item><item><title><![CDATA[Reply to How to Create dynamically JSON object in QT ? on Thu, 15 Feb 2018 11:59:21 GMT]]></title><description><![CDATA[<p dir="auto">I'm sorry but I don't understand what you want to achieve. Creating a simple JSON message is something akin to:</p>
<pre><code>QJsonObject obj;
obj.insert("someKey", "someValue");
obj.insert("someOtherKey", 123);
obj.insert("array", QStringList() {"a", "b"});
QJsonDocument doc(obj).toJson(); // &lt;- this is your JSON string
</code></pre>
<p dir="auto">To create multiple messages, just repeat the process... I don't see a problem here. But then again, as said, I don't understand what your question really is about.</p>
]]></description><link>https://forum.qt.io/post/442292</link><guid isPermaLink="true">https://forum.qt.io/post/442292</guid><dc:creator><![CDATA[sierdzio]]></dc:creator><pubDate>Thu, 15 Feb 2018 11:59:21 GMT</pubDate></item><item><title><![CDATA[Reply to How to Create dynamically JSON object in QT ? on Thu, 15 Feb 2018 09:03:49 GMT]]></title><description><![CDATA[<p dir="auto">correct<br />
But i need to create multiple JSON message dynamically<br />
and from that multiple JSON messages<br />
i need to filler that JSON message base on their property type and properties</p>
<p dir="auto">so How i will create JSON messages and how i will add different property type in JSON  ??</p>
]]></description><link>https://forum.qt.io/post/442250</link><guid isPermaLink="true">https://forum.qt.io/post/442250</guid><dc:creator><![CDATA[Mayank Thakor]]></dc:creator><pubDate>Thu, 15 Feb 2018 09:03:49 GMT</pubDate></item><item><title><![CDATA[Reply to How to Create dynamically JSON object in QT ? on Thu, 15 Feb 2018 08:17:51 GMT]]></title><description><![CDATA[<p dir="auto"><a href="https://doc.qt.io/qt-5/json.html" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qt-5/json.html</a></p>
]]></description><link>https://forum.qt.io/post/442240</link><guid isPermaLink="true">https://forum.qt.io/post/442240</guid><dc:creator><![CDATA[sierdzio]]></dc:creator><pubDate>Thu, 15 Feb 2018 08:17:51 GMT</pubDate></item></channel></rss>