Object type does not contain any attributes or methods by default. You need to cast it to a concrete type to access any properties on a particular instance. For instance, if you had a
PurchaseOrderWrapper class defined as below, you would deserialize into a
List<PurchaseOrderWrapper> instead of
public with sharing class PurchaseOrderWrapper
final String format;
Map<String, Object> response = (Map<String, Object>)JSON.deserializeUntyped(payload);
List<Object> data = (List<Object>)response.get('purchaseOrders');
List<PurchaseOrderWrapper> data =
You can read more about the
Object type in the
Apex Developer Guide under Primitive Data Types:
Any data type that is supported in Apex. Apex supports primitive data types (such as Integer), user-defined custom classes, the sObject generic type, or an sObject specific type (such as Account). All Apex data types inherit from Object.
You can cast an object that represents a more specific data type to its underlying data type. For example:
Object obj = 10;
// Cast the object to an integer.
Integer i = (Integer)obj;
The next example shows how to cast an object to a user-defined type—a custom Apex class named MyApexClass that is predefined in your organization.
Object obj = new MyApexClass();
// Cast the object to the MyApexClass custom type.
MyApexClass mc = (MyApexClass)obj;
// Access a method on the user-defined class.