<?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[Parsing JSON with Ofelia]]></title><description><![CDATA[<p>I'm trying to retrieve and parse some simple JSON from a url. This is what works so far for me (although I'm not sure if ofLoadURL is what I should be using - there seem to be many ways to retrieve content from a url):</p>
<pre><code>ofelia f;
resp = ofLoadURL(&quot;https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY&amp;date=2024-06-06&quot;);
text = resp.data:getText();
print(text);
return(anything);
</code></pre>
<p>I can output it as text but cannot understand how to parse it from buffer or the string to JSON. I've been using this as an example (<a href="https://stackoverflow.com/questions/4800605/iterating-through-objects-in-jsoncpp" rel="nofollow">https://stackoverflow.com/questions/4800605/iterating-through-objects-in-jsoncpp</a>) so just to get one entry from the JSON should it be something like this? - not sure how to change it to work in Ofelia:</p>
<pre><code>Json::Value root;
Json::Reader parser;

// Parse the json (using the text in the code above)
parser.parse( text, root );

// Get the url
print(root[&quot;url&quot;]);
</code></pre>
]]></description><link>http://forum.pdpatchrepo.info/topic/14780/parsing-json-with-ofelia</link><generator>RSS for Node</generator><lastBuildDate>Tue, 21 Apr 2026 17:13:22 GMT</lastBuildDate><atom:link href="http://forum.pdpatchrepo.info/topic/14780.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 27 Jun 2024 14:15:55 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Parsing JSON with Ofelia on Thu, 27 Jun 2024 14:15:55 GMT]]></title><description><![CDATA[<p>I'm trying to retrieve and parse some simple JSON from a url. This is what works so far for me (although I'm not sure if ofLoadURL is what I should be using - there seem to be many ways to retrieve content from a url):</p>
<pre><code>ofelia f;
resp = ofLoadURL(&quot;https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY&amp;date=2024-06-06&quot;);
text = resp.data:getText();
print(text);
return(anything);
</code></pre>
<p>I can output it as text but cannot understand how to parse it from buffer or the string to JSON. I've been using this as an example (<a href="https://stackoverflow.com/questions/4800605/iterating-through-objects-in-jsoncpp" rel="nofollow">https://stackoverflow.com/questions/4800605/iterating-through-objects-in-jsoncpp</a>) so just to get one entry from the JSON should it be something like this? - not sure how to change it to work in Ofelia:</p>
<pre><code>Json::Value root;
Json::Reader parser;

// Parse the json (using the text in the code above)
parser.parse( text, root );

// Get the url
print(root[&quot;url&quot;]);
</code></pre>
]]></description><link>http://forum.pdpatchrepo.info/topic/14780/parsing-json-with-ofelia</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/14780/parsing-json-with-ofelia</guid><dc:creator><![CDATA[garrett]]></dc:creator><pubDate>Thu, 27 Jun 2024 14:15:55 GMT</pubDate></item></channel></rss>