sivaganesh sivakumar
sivaganesh sivakumar

Reputation: 369

Parsing JSONArray when no key is present using restassured

i am using restassured to test my rest APIs and I have a scenario where my rest API returns a JSONArray without any key value like below. While browsing through multiple questions i havent seen similar JSONArray handled without key value. Verifying such a JSON is supported by RestAssured ?

[ "Test_1 Bundle_01", "Test_2 Bundle_02", "Test_3 Bundle_03" ]

Upvotes: 1

Views: 790

Answers (1)

sivaganesh sivakumar
sivaganesh sivakumar

Reputation: 369

Found a way to do this by using jsonpath.

List<String> newlist = JsonPath.with(response.asInputStream()).get("$");
System.out.println(newlist.get(0).toString());

By using jsonpath and storing the response in a list of string, individual string can be accessed easily.

Upvotes: 1

Related Questions