Im using JsonPath to Assert on some of the values returned from an api response but having a small issue with asserting the response.
Heres the response i get:
[{"Id":75969,StartDate":"2016-07-01","EndDate":"2021-04-30","duration":5640}]
Lets say i want to Assert on the Start date. The method I created looks like this:
public void checkStartDate(String expectedStartDate) {
String responseBody = response.getBody().asString();
JsonPath values = new JsonPath(responseBody);
Assert.assertEquals(expectedStartDate,values.getString("startDate"));
}
The expectedStartDate that i pass in to the method is 2016-07-01 and the date i get back from the JsonPath object is [2016-07-01] which causes the assertion to fail.
Does anyone know what i can do to with JsonPath in order to remove the square braces from the value that im extracting from the response string?