<?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[Qt und json]]></title><description><![CDATA[<p>Guten Morgen,</p>
<p>ich beschäftige mich derzeit mit json und bin auf etwas gestoßen was ich nicht lösen kann. Hier der Code vielleicht könnt ihr mir dabei helfen.</p>
<pre><code>QEventLoop eventLoop;

    QNetworkAccessManager mgr;
    QObject::connect(&amp;mgr, SIGNAL(finished(QNetworkReply*)), &amp;eventLoop, SLOT(quit()));

    QNetworkRequest req( QUrl( QString(&quot;https://euw.api.pvp.net/api/lol/euw/v1.4/summoner/by-name/Urb?api_key=fc656ab0-abd0-40b6-810b-c71f4243570f&quot;) ) );
    QNetworkReply *reply = mgr.get(req);
    eventLoop.exec(); 

    if (reply-&gt;error() == QNetworkReply::NoError) {

        QString strReply = (QString)reply-&gt;readAll();

        qDebug() &lt;&lt; &quot;Response:&quot; &lt;&lt; strReply;
        QJsonDocument jsonResponse = QJsonDocument::fromJson(strReply.toUtf8());

        QJsonObject jsonObj = jsonResponse.object();

        qDebug() &lt;&lt; &quot;id:&quot; &lt;&lt; jsonObj[&quot;id&quot;].toString();

        delete reply;
    }
    else {
        qDebug() &lt;&lt; &quot;Failure&quot; &lt;&lt;reply-&gt;errorString();
        delete reply;
    }
</code></pre>
<p>Url response:</p>
<pre><code>{&quot;urb&quot;:{&quot;id&quot;:20197099,&quot;name&quot;:&quot;Urb&quot;,&quot;profileIconId&quot;:589,&quot;summonerLevel&quot;:30,&quot;revisionDate&quot;:1464122887000}}
</code></pre>
<p>Ich bekomme die gewünschte &quot;id&quot; nicht angezeigt. Wenn ich das ganze aber mit dieser json Datei (sehr simple)</p>
<pre><code>{
&quot;one&quot;:&quot;eins&quot;
}
</code></pre>
<p>versuche und ich möchte &quot;one&quot; haben, bekomme ich die &quot;eins&quot;! Was mache ich falsch, jemand eine Idee?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/338126/qt-und-json</link><generator>RSS for Node</generator><lastBuildDate>Wed, 15 Apr 2026 13:12:50 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/338126.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 25 May 2016 08:26:54 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Qt und json on Wed, 25 May 2016 08:26:54 GMT]]></title><description><![CDATA[<p>Guten Morgen,</p>
<p>ich beschäftige mich derzeit mit json und bin auf etwas gestoßen was ich nicht lösen kann. Hier der Code vielleicht könnt ihr mir dabei helfen.</p>
<pre><code>QEventLoop eventLoop;

    QNetworkAccessManager mgr;
    QObject::connect(&amp;mgr, SIGNAL(finished(QNetworkReply*)), &amp;eventLoop, SLOT(quit()));

    QNetworkRequest req( QUrl( QString(&quot;https://euw.api.pvp.net/api/lol/euw/v1.4/summoner/by-name/Urb?api_key=fc656ab0-abd0-40b6-810b-c71f4243570f&quot;) ) );
    QNetworkReply *reply = mgr.get(req);
    eventLoop.exec(); 

    if (reply-&gt;error() == QNetworkReply::NoError) {

        QString strReply = (QString)reply-&gt;readAll();

        qDebug() &lt;&lt; &quot;Response:&quot; &lt;&lt; strReply;
        QJsonDocument jsonResponse = QJsonDocument::fromJson(strReply.toUtf8());

        QJsonObject jsonObj = jsonResponse.object();

        qDebug() &lt;&lt; &quot;id:&quot; &lt;&lt; jsonObj[&quot;id&quot;].toString();

        delete reply;
    }
    else {
        qDebug() &lt;&lt; &quot;Failure&quot; &lt;&lt;reply-&gt;errorString();
        delete reply;
    }
</code></pre>
<p>Url response:</p>
<pre><code>{&quot;urb&quot;:{&quot;id&quot;:20197099,&quot;name&quot;:&quot;Urb&quot;,&quot;profileIconId&quot;:589,&quot;summonerLevel&quot;:30,&quot;revisionDate&quot;:1464122887000}}
</code></pre>
<p>Ich bekomme die gewünschte &quot;id&quot; nicht angezeigt. Wenn ich das ganze aber mit dieser json Datei (sehr simple)</p>
<pre><code>{
&quot;one&quot;:&quot;eins&quot;
}
</code></pre>
<p>versuche und ich möchte &quot;one&quot; haben, bekomme ich die &quot;eins&quot;! Was mache ich falsch, jemand eine Idee?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2496947</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2496947</guid><dc:creator><![CDATA[Turro]]></dc:creator><pubDate>Wed, 25 May 2016 08:26:54 GMT</pubDate></item><item><title><![CDATA[Reply to Qt und json on Wed, 25 May 2016 08:43:24 GMT]]></title><description><![CDATA[<p>Das Hauptattribut ist doch &quot;urb&quot;.<br />
Probiere daher mal</p>
<pre><code class="language-cpp">jsonObj[&quot;urb&quot;][&quot;id&quot;]
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2496951</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2496951</guid><dc:creator><![CDATA[Th69]]></dc:creator><pubDate>Wed, 25 May 2016 08:43:24 GMT</pubDate></item><item><title><![CDATA[Reply to Qt und json on Wed, 25 May 2016 12:51:08 GMT]]></title><description><![CDATA[<p>Th69 schrieb:</p>
<blockquote>
<p>Das Hauptattribut ist doch &quot;urb&quot;.<br />
Probiere daher mal</p>
<pre><code class="language-cpp">jsonObj[&quot;urb&quot;][&quot;id&quot;]
</code></pre>
</blockquote>
<p>Das hat leider nicht funktioniert, aber du hast mich auf eine Idee gebracht und zwar</p>
<pre><code>QJsonObject jsonObjtwo = jsonObj[&quot;urb&quot;].toObject();

        qDebug() &lt;&lt; &quot;id:&quot; &lt;&lt; jsonObjtwo[&quot;id&quot;].toInt();
</code></pre>
<p>Ich habe das Hauptattribut an ein weiteres Objekt übergeben und dann konnte ich mit &quot;jsonObjetwo&quot; auf die &quot;id&quot; zugreifen, jedoch anstatt to.String habe ich to.Int verwendet und es funktioniert.</p>
<p>Danke für Hinweis.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2496983</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2496983</guid><dc:creator><![CDATA[Turro]]></dc:creator><pubDate>Wed, 25 May 2016 12:51:08 GMT</pubDate></item><item><title><![CDATA[Reply to Qt und json on Wed, 25 May 2016 13:39:04 GMT]]></title><description><![CDATA[<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2496994</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2496994</guid><dc:creator><![CDATA[Th69]]></dc:creator><pubDate>Wed, 25 May 2016 13:39:04 GMT</pubDate></item></channel></rss>