How to handle JSON response of array or object with Volley and Adapter
<p>If searching for 2 or more fields the JSON response is an array of data: </p>

<pre><code>{
"query": {
    "count": 2,
    "created": "2016-08-22T16:57:40Z",
    "lang": "en-US",
    "results": {
        "data": [{
                .
                .
                .
        }]
      }
   }
}
</code></pre>

<p>But when searching for only 1 field the JSON response is an object of data:</p>

<pre><code>{
"query": {
    "count": 1,
    "created": "2016-08-22T17:03:53Z",
    "lang": "en-US",
    "results": {
        "data": {
                .
                .
                .
       }
     }
   }
}
</code></pre>

<p>I have it working fine with an array of data. But when a single object is returned the screen is blank. The logcat gives me a typeMismatch error that I'm pretty certain is due to this line</p>

<pre><code>JSONArray data = results.getJSONArray("data");
</code></pre>

<p>Can I use Volley to handle both types of responses? Don't know if I need to create another adapter or what? Read a couple of similar posts but they all dealt with Retrofit and GSON so not certain the answers are applicable. Thanks</p>