@Test
  public void doAPITestExample() throws JSONException {
    Response response = RestAssured.given()
        .log().all()
        .get("http://localhost:8081/mockservice");
    response.then()
        .log().all()
        .assertThat().statusCode(200);
    String body = response.getBody().asString();
    System.out.println("Body:" + body);
    /*
      {"datetime": "2018-06-21 17:48:07.488384", "data": [{"foo": "bar"}, {"test": "this is test data"}]}
    */
    // able to compare entire body with JSONAssert, strict=false
    Object data = response.then().extract().path("data");
    System.out.println("Response data:");
    System.out.println(data.getClass()); // class java.util.ArrayList
    System.out.println(data.toString());
    // JSONAssert data with strict=false
    String expectedJSON = "{\"data\":[{\"foo\": \"bar\"}, {\"test\": \"this is test data\"}]}";
    JSONAssert.assertEquals(expectedJSON, response.getBody().asString(), false);
    // How do I extract JSON with JSONPath, use JSONAssert together?
  }
  Object data = response.then().extract().path("data");
  String dataString = response.then().extract().path("data").toString();
  JSONArray dataArray = (JSONArray) JSONParser.parseJSON(dataString);  org.json.JSONException: Unterminated object at character 24 of [{foo=bar}, {test=this is test data}]--
You received this message because you are subscribed to the Google Groups "REST assured" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
   String dataString = response.then().extract().path("data").toString();
   JSONArray dataArray = (JSONArray) JSONParser.parseJSON(dataString);  org.json.JSONException: Unterminated object at character 24 of [{foo=bar}, {test=this is test data}]
Please see details in Approach 2 - parse extracted data with JSONParser
String jsonString =Â response.asString();
Now you can use any library you like to extract the "data" object.--
You received this message because you are subscribed to the Google Groups "REST assured" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--Sent from my phone
--
You received this message because you are subscribed to the Google Groups "REST assured" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured+unsubscribe@googlegroups.com.
response().then().body("data", SameJSONAs("[{\"foo\": \"bar\"}, {\"test\": \"this is test data\"}]").allowAnyArrayOrdering())--
You received this message because you are subscribed to a topic in the Google Groups "REST assured" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rest-assured/nwUnYq5KdTk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to rest-assured...@googlegroups.com.