How do I parse a jsonObject which is in a given format in Apex?
I need List
You can use the deserializeUntyped
function to work with the JSON in plain object/list/map objects. You just need to remember to cast everything to the expected type (exactly as you would in Java). So to access the id field of each item, you'd do
public void parse() {
Map<String, Object> root = (Map<String, Object>)JSON.deserializeUntyped(getJsonToParse());
List<Object> items = (List<Object>)root.get('items');
for (Object item : items) {
Map<String, Object> i = (Map<String, Object>)item;
System.debug(i.get('id'));
}
}
which generates this debug output: