I'm new to Apex and I would appreciate some help with the following:
The code below returns the entire list from input:
public static string input ='[{"item1": 1,"item2": "2","item3": [{"child1": "11","child2": "22","child3": 33}]},{"item1": "aa","item2": "bb","item3": [{"child1": "22","child2": "33","child3": 12}]}]';
List<Object> jsonParsed = (List<Object>) JSON.deserializeUntyped(input);
System.debug(jsonParsed);
and I want to get the child of "item3", so that I can read:
"item1": "1" "child1": "11" "child2": "22" "child3": 33
I have tried the code below without success, and I get item1 but null for child 1,2 and 3.
for(Object jsonParsed : jsonParsed){
Map<String,Object> ind = (Map<String,Object> )jsonParsed;
System.debug('item1 = '+ ind.get('item1'));
System.debug('child1 = '+ ind.get('item3.child1[0]'));
System.debug('child2 = '+ ind.get('item3.child2[1]'));
System.debug('child3 = '+ ind.get('item3.child3[2]'));
}