Apex · Salesforce

System.JSONException: Apex Type unsupported in JSON: Object

The Salesforce JSON.deserialize(String, Type) method cannot deserialize from JSON into generic Object, or into objects with generic Object fields. You can deserialize into concrete types such as “String” or “Integer”.

If you have defined your field types as Object, e.g. public Object error, you need to replace Object with the appropriate data type, i.e. StringInteger, etc.

Once you have updated the JSON2Apex generated Apex class with proper data structure then you should fine with deseialize your JSON.

PS. when you use JSON2Apex to generate Apex class by default assign to object since JSON2Apex doesn’t guess what type should for null values.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s