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. String
, Integer
, 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.