What I'm trying to do here is iterate inside a Json Object obtained from an API Call in order to search a value related from a Key. However I'm failing in obtaining the tuples from every iteration. From the following code:
public void findResponseValue(String param, String inputValue){
ArrayList jsonArray = response.getBody().jsonPath().get("");
Iterator iterator = jsonArray.iterator();
while(iterator.hasNext()){
System.out.println(iterator.next());
iterator.next();
}
I receive the following error
java.lang.ClassCastException: class java.util.HashMap cannot be cast to class java.lang.String (java.util.HashMap and java.lang.String are in module java.base of loader 'bootstrap')
It correctly iterates over the arrayList, but it fails trying to take a value from it.
Response Body example
[
{
"creationDate": "2017-05-29T07:45:43Z",
"createdBy": "YYY.YYY",
"lastUpdate": "2018-09-26T10:10:12Z",
"updatedBy": "XXX.XXX",
"id": 22,
"partner": "ALS",
"countries": [
],
"countriesCodes": "NL",
"salesChannels": [
{
"code": "Integrated"
}
],
"touchPoints": [
],
"serviceEntity": "AWPNL",
"flag": false,
"activated": true,
"type": "dcx"
},
{
"creationDate": "2017-06-01T13:22:29Z",
"createdBy": "YYY.YYY",
"lastUpdate": "2017-11-30T12:24:36Z",
"updatedBy": "MMM.T.NNN",
"id": 39,
"partner": "ALS",
"countries": [
],
"countriesCodes": "ES",
"salesChannels": [
{
"code": "Integrated"
}
],
"touchPoints": [
],
"serviceEntity": "AWPES",
"flag": false,
"activated": true,
"type": "dcx"
}
]
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)