title: Trouble parsing JSON to string in Java
body: <p>I have the following JSON:</p>
  
  <pre><code>{
      data: [
      {
          objectType: "ServiceForbiddenException",
          item: {
              service: "users",
              action: "index",
              code: 403,
              message: "Access to the service [users] is forbidden."
          }
      }
      ]
  }
  </code></pre>
  
  <p>I tried parsing it using the following snippet:</p>
  
  <pre><code>       String bodyData = iRes.body().string();
         try{
              JSONObject body = new JSONObject(bodyData);
              JSONArray data = body.getJSONArray("data");
              JSONObject type =  data.getJSONObject(0);
              JSONArray item = data.getJSONArray(1);
  
          }
          catch (Exception e)
          {
              e.printStackTrace();
          }
  </code></pre>
  
  <p>the problem is that is that <code>JSONArray data = body.getJSONArray("data");</code>is actually the whole data, and not an array.</p>
  
  <p>How do I parse it correctly? are there better libs / ways to parse a json in Java (Android)</p>