Best practices to handle JSON data for API SDK
<p>The company I work for has an API and I am porting that API over to PHP. Right now, the API returns to me a large JSON object and I'm trying to figure out how I should handle the data.  I could have a whole bunch of "get" methods, like:</p>

<pre><code>$t = new APIThing();
$t-&gt;getJSONObjects();
for ($i=0; ...) {
   $t-&gt;getHeadline($i);
}
</code></pre>

<p>Or, I could return the JSON object and let people play with the data themselves, so that would be something like this</p>

<pre><code>$t = new APIThing();
$t-&gt;getJSONObjects();
foreach ($t as $u) {
    echo $u-&gt;headline;
}
</code></pre>

<p>So what do you think?  Just expose the JSON object or wrap the whole thing up into functions?</p>
