How to fetch JSON object from Json array in REstAssured
<p><strong>Can anyone please help me to solve this scenario:</strong></p>

<p>I am new to <code>RestAssured</code> and handling <code>JSON</code> in our automation script.
I have an <code>API</code> whose response is <code>JSONArray</code> i.e.,</p>

<pre><code>  [{
    "id": 1002,
    "entity": "testcase",
    "fieldName": "TextName",
    "displayName": "Name"
  }, {
    "id": 1003,
    "entity": "testcase",
    "fieldName": "steps",
    "displayName": "TestSteps"
  }]
</code></pre>

<p>While automation, for verification i need to fetch the reponse.
I have tried the below one but not getting expected output</p>

<pre><code> String API = "/field/entity/testcase"
 Response response = given().auth().preemptive().basic("test.manager",     "test.manager").when().get(API);
    JSONObject JSONResponseBody = new   JSONObject(response.body().asString());
    Assert.assertEquals(JSONResponseBody.getString("fieldName"), "TextName");
</code></pre>

<p>and also i tried with this:</p>

<pre><code>    JSONArray array = new JSONArray();
    JsonObject JSONResponseBody = array.getJsonObject(0);
</code></pre>

<p>Thanks Inadvance</p>