i have the below Json structure,
{
"MyData": {
"Type": "ABC",
"Id": "567",
"Number": "888"
},
"RefId": "9999",
"DataValues": [
{
"NumberList": [
"7777777"
],
"NumberId": "888888888",
"Phone": "0000000",
}
]
}
Below is my code to parse the Json to fetch the value in NumberList,
String jsonResponse = "{ \"MyData\": {\"Type\": \"ABC\",\"Id\": \"567\",\"Number\": \"888\"},\"RefId\": \"9999\",\"DataValues\": [{\"NumberList\": [\"7777777\"],\"NumberId\": \"888888888\",\"Phone\": \"0000000\" }]}";
List<Map<String, Object>> responseValue = com.jayway.jsonpath.JsonPath.parse(jsonResponse).read("NumberList");
String number = responseValue.get(0).get("NumberList").toString().replace("[", "").replace("]", "");
System.out.println("number --> " + number);
The output is
number --> "7777777"
Double inverted quotes are present in the output
How to get the correct output here, need just the value 7777777
With restassured jsonPath, i get the correct output for below code.
List<Map<String, Object>> responseValue = new io.restassured.path.json.JsonPath(jsonResponse).get("NumberList");
String number = responseValue.get(0).get("NumberList").toString().replace("[", "").replace("]", "");
But i dont want to use rest assured jsonPath.
How to get the correct output with jayway JsonPath ??