General Tech Bugs & Fixes . 1 year ago

Is there any way to handle “Array response” return from API call

Is there any way to handle “Array response” return from API call

2 views   2   0 likes   0 shares Tuteehub forum manpreet 2 answers
tuteehub_quiz
Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

profilepic.png

Tuteehub forum answer Answers (2)


profilepic.png
manpreet Tuteehub forum best answer Best Answer 1 year ago

I'm testing a API where it return response as a Array,I am finding it difficult in storing in list or Array?

I am using JsonPath to fetch the records

API response looks like this

[
    "String1",
    "String2",
    "String3",
    "String4",
    "String5"
]

I am Using below code

Response response;
JsonPath jsonPathEvaluator = response.jsonPath();
jsonPathEvaluator.getString("[0]");
2 views   0 shares
profilepic.png
manpreet 1 year ago
{  
   "Strings":[  
      "String1",
      "String2",
      "String3",
      "String4",
      "String5"
   ]
}

JsonArray arrObj = empObj.getJsonArray("Strings");

 
2 views   0 shares

Related Tags