When you use JSON.deserializeUntyped(data)
, you need to perform type casting to tell the Apex compiler what kind of object you're working with or you'll get errors because the type Object
has no property baseVolume
(e.g.).
One way to accomplish this would be:
for (Object obj : meta.keyset()){
Data d = (DataMap<String, Object>)meta.get(obj);
System.debug(d.baseVolumeget('baseVolume');)
}
This converts the untyped Object instance into a Map, whose get
method you can use to obtain properties. (Unfortunately, you can't cast directly to a Data
instance from a Map; please pardon my oversight).
If you do want to work with class instances rather than untyped Maps, you could also deserialize into a Map<String, Data>
, which would have a keySet
you could then iterate over.