I am currently saving a JSON response in a map and I'm struggling iterating over the nested HashMap values. For example:
- Index 0
Index 1 -> Key: "Example":
- Key: "Example 2"
Values "Example 3" (ArrayList)
- Key, Values... (HashMap)
My map looks like:
HashMap<Object, Object> map = (HashMap< Object, Object >) result.getBody();
Which is saving the result from the following Spring Boot ResponseEntity:
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<Object> result = restTemplate.exchange(url, HttpMethod.GET,
entity, Object.class);
And to iterate over the first set of indexes I am doing:
for (Map.Entry<Opportunities, Opportunities> entry : resultMap.entrySet()) {
System.out.println(entry.getValue());
}
How can I iterate over the values inside Index 1? I have tried adapting this solution but with no luck. Thanks in advance.
Edit - The JSON response looks like:
{
"metadata": {
"page": 0,
"pageSize": 1,
"pageCount": 10,
"totalCount": 10
},
"Users": [
{
"ID": 1216411,
"name": "John",
"name": "John",
"Order_Details": {
"id": 1216411234,
"item": "Electric Razer",
"region": {
"name": "United States",
"regionCode": "US"
}
},
"Suppliers": [
...