Member-only story
Creating Json Object From string in Java (Rest-assured):
Jun 3, 2021
https://mvnrepository.co m/artifact/org.json/json/2 0210307
get org.json from maven
add below dependency to your maven:
<!--
https://mvnrepository.com/artifact/org.json/js
on -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20210307</version>
</dependency>
Now import these:
//import these
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONArray;
Now you can convert a json string to json object just like that:
//now you can convert string to array andobject without having complicated mapsand objectstry {JSONArray jsonArray = newJSONArray("[1,2,3,4,5]");//you can give entire jsonObject hereJSONObject jsonObject = newJSONObject("{\"name\": [\"praveen\"]}");System.out.println("outputarray: " +