I am trying to modify my code to resolve this error, but not sure why it isn't working. I am returning an array of JSON objects and the json is valid. What do I need to modify in the code below to resolve this error?
Error message: Error: Method does not exist or incorrect signature: void get(String) from the type Object
HttpResponse response = h.send(request);
if (response.getStatusCode() == 200) {
List<Object> arr =(List<Object>)JSON.deserializeUntyped(response.getBody());
Map<String, Object> dataNode = (Map<String, Object>)arr[0].get('Data');
System.debug('data node ------------->' + dataNode);
}
Best Answer
In addition of casting the Object at the first index of
arr
to a map you also need to cast the Object that comes back fromData
to aMap<string, Object>
as well.As that is starting to get unwieldy due to the multiple casts it would be helpful to split it out to a few lines.