-2

I am currently trying to Automate a API using HTTP client jars. I have stored the response of API which is in JSON format into a Java String object. As next step, I would like to convert the response into a JSON Object, which would help me to easily traverse the object. Can you please let me know which API jars or additional libraries I can use to convert the String object into JSON Object.

apiOutput contains the response which is in the below format.

String apiOutput= {
    "title": "foo",
    "body": "bar",
    "userId": 1,
    "id": 101
}

I would like to convert this response into a JSON object to traverse easily.

TheWildHealer
  • 1,546
  • 1
  • 15
  • 26
Vishal Gada
  • 201
  • 3
  • 12

1 Answers1

1

Simply like this :

import org.json;

JSONObject obj = new JSONObject(jsonString);
TheWildHealer
  • 1,546
  • 1
  • 15
  • 26