I have below JSON I need to deserialize this in response class

    "resource": {
        "revision": {
            "id": 44,
            "rev": 28,
            "fields": {
                "System.AreaPath": "DemovR V2",
                "System.TeamProject": "DemovR V2",
                "System.IterationPath": "DemovR V2"

My response class

public class getUpdatedEvent
        public cls_resource resource;
    public class cls_resource {
        cls_revision revision;
     class cls_revision {
        public Integer id;  //44
        public Integer rev; //28
        public cls_fields fields;
    class cls_fields {
        object fields;

getting error

System.JSONException: Apex Type unsupported in JSON: Object

whereas it is working without response class what I tried so far.

PayLoad__c pl = [select Load__c from PayLoad__c limit 1];
Map<String, Object> res_map =(Map<String, Object>)JSON.deserializeUntyped(pl.Load__c);
Map<String, Object> reso = (Map<String, Object>) res_map.get('resource');
Map<String, Object> reso_fields = (Map<String, Object>) reso.get('revision');
Map<String, Object> fields = (Map<String, Object>) reso_fields.get('fields');

Your code is more likely to work if you change the class to:

class cls_fields {
    Map<String, String> fields;

and perhaps also:

Map<String, String> fields = (Map<String, String>) reso_fields.get('fields');


Your JSON.deserializeUntyped approach looks like the only way to go based on your comments. You can write code to transfer the data into your classes, if you need all the information to be conveniently accessible.

| improve this answer | |
  • What if we get integer or another data type? – Ragul Feb 3 at 9:24
  • Then yes declare as Map<String, Object> and cast. – Keith C Feb 3 at 9:50
  • It's not working, throwing error Apex Type unsupported in JSON: Object – Ragul Feb 3 at 10:35
  • My bad. I'll add an alternative answer. – Keith C Feb 3 at 10:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.