title: How to parse json response with array list
body: <p>I have a below response which I am unable to validate due to response is starting from <code>JSON</code> object 0. Thats means if more than one object, the response will start from 0 to the number of objects you have.</p>
  
  <p>I have tried this but its not working and ends up with stack over flow error.</p>
  
  <pre><code>public static void Location_ContactValidation(Response response, String code, String message, ExtentTest log) {
   try {
    softAssert = new SoftAssert();
    org.json.JSONObject jsonObject = new org.json.JSONObject(response);
    org.json.JSONObject getSth = jsonObject.getJSONObject("status");
    status_Message = getSth.get("message");
    softAssert.assertEquals(code, code);
    softAssert.assertEquals(message, status_Message);
    log.log(LogStatus.INFO, "Validation: The status code is " + code);
    log.log(LogStatus.INFO, "Validation: The status message is " + status_Message.toString());
  
   } catch (Exception e) {
    log.log(LogStatus.INFO, "Validation: The status code is " + code);
    if (status_Message != null) {
     log.log(LogStatus.INFO, "Validation: The status message is " + status_Message.toString());
    }
    System.out.println(e.getMessage());
    if (softAssert != null) {
     softAssert.assertAll();
    }
   }
  }
  </code></pre>
  
  <p>Stack overflow error as flows- </p>
  
  <pre><code>java.lang.StackOverflowError
      at org.json.JSONObject.wrap(JSONObject.java:1746)
      at org.json.JSONArray.&lt;init&gt;(JSONArray.java:176)
      at org.json.JSONObject.wrap(JSONObject.java:1747)
      at org.json.JSONObject.populateMap(JSONObject.java:1167)
  </code></pre>
  
  <p>And here is the response I want to parse</p>
  
  <pre><code>{
      "0": {
          "status": "OK",
          "data": {
              "id": "*************",
              "mobile": "*************"
          },
          "message": "Submitted Successfully"
      },
      "status": "OK"
  }
  </code></pre>
  
  <p>I need to validate the mobile number, both the status and message.
  But not able to do it.
  If one more number is send with request then the response increases and to array gets created first as shown with <code>0</code> then with <code>1</code>.</p>
  
  <p>I appreciate your help.</p>