0

Hi All I am trying to deserialize the below response but getting values null every time.

Wrapper class used

public class APIResponse{
    public cls_InstantIDResponseEx InstantIDResponseEx;
    class cls_InstantIDResponseEx {
        public String xmlns;   
        public cls_response response;
    }
     public class cls_response {
        public cls_Header Header;
        public cls_Result Result;
        public String Pdf;  
    }
    class cls_Header {
        public String Status;  //0
        public String TransactionId;    //173412791R781092
    }
    class cls_Result {
        public cls_InputEcho InputEcho;
        public String UniqueId; //190178862744
        public cls_VerifiedInput VerifiedInput;
        public String DOBVerified;
        public String NameAddressSSNSummary;   //2
        public cls_NameAddressPhone NameAddressPhone;
        public cls_ComprehensiveVerification ComprehensiveVerification;
        public cls_ReversePhone ReversePhone;
        public cls_SSNInfo SSNInfo;
        public cls_ChronologyHistories ChronologyHistories;
        public String AdditionalScore1; //0
        public String AdditionalScore2; //0
        public cls_CurrentName CurrentName;
        public String PassportValidated;
        public String DOBMatchLevel;   //0
        public String SSNFoundForLexID;
        public String AddressPOBox;
        public String AddressCMRA;
        public String InstantIDVersion; //1
        public String EmergingId;
        public String AddressStandardized;
        public String AddressSecondaryRangeMismatch;    //N
        public String BureauDeleted;
        public String ITINExpired;
        public String IsPhoneCurrent;
        public String PhoneLineType;    //1
        public String PhoneLineDescription; //W
    }
    class cls_InputEcho {
        public cls_Name Name;
        public cls_Address Address;
        public String SSN;  //665108510
        public String HomePhone;    //4698555087
    }
    class cls_Name {
        public String First;    //KIRAN
        public String Last; //MALAKAR
    }
    class cls_Address {
        public String StreetNumber; //47460
        public String StreetName;   //CAYLEE
        public String StreetSuffix; //CT
        public String StreetAddress1;   //47460 CAYLEE CT
        public String City; //SHELBY TOWNSHIP
        public String State;    //MI
        public String Zip5; //48315
        public String Zip4; //5048
    }
    class cls_VerifiedInput {
        public cls_Name Name;
    }
    class cls_NameAddressPhone {
        public String Summary;  //1
        public String Type; //P
    }
    class cls_ComprehensiveVerification {
        public String ComprehensiveVerificationIndex;  //10
        public cls_RiskIndicators RiskIndicators;
        public cls_PotentialFollowupActions PotentialFollowupActions;
    }
    class cls_RiskIndicators {
        public cls_RiskIndicator[] RiskIndicator;
    }
    class cls_RiskIndicator {
        public String RiskCode; //51
        public String Description;  //The input last name is not associated with the input SSN
        public String Sequence;    //1
    }
    class cls_PotentialFollowupActions {
        public cls_FollowupAction[] FollowupAction;
    }
    class cls_FollowupAction {
        public String RiskCode; //B
        public String Description;  //Verify name with Social (via SSN card, DL if applicable, paycheck stub, or other Government Issued ID)
    }
    class cls_ReversePhone {
        public cls_Name Name;
        public cls_Address Address;
    }
    class cls_SSNInfo {
        public String Valid;    //G
        public String IssuedLocation;   //Louisiana
        public cls_IssuedStartDate IssuedStartDate;
        public cls_IssuedEndDate IssuedEndDate;
    }
    class cls_IssuedStartDate {
        public Integer Year;    //2005
        public Integer Month;   //6
        public Integer Day; //2
    }
    class cls_IssuedEndDate {
        public String Year;    //2006
        public String Month;   //9
        public String Day; //1
    }
    class cls_ChronologyHistories {
        public cls_ChronologyHistory[] ChronologyHistory;
    }
    class cls_ChronologyHistory {
        public cls_Address Address;
        public cls_DateFirstSeen DateFirstSeen;
        public cls_DateLastSeen DateLastSeen;
        public boolean IsBestAddress;
    }
    class cls_DateFirstSeen {
        public String Year;    //2012
        public String Month;   //5
    }
    class cls_DateLastSeen {
        public String Year;    //2023
        public String Month;   //5
    }
    class cls_CurrentName {
        public String First;    //JANET
        public String Last; //BOWEN
    }
    public APIResponse parse(String json){
        return (APIResponse) System.JSON.deserialize(json, APIResponse.class);
    }

   
}




String responsebody=`'{"http_status_code":"200","response":{"InstantIDResponseEx":{"response":{"Result":{"InputEcho":{"SSN":"false","Name":{"First":"0","Last":"false"},"Address":{"Zip5":"false"},"HomePhone":"false"},"UniqueId":"false","VerifiedInput":{"Name":{"First":"false","Middle":"false","Last":"false"},"Address":{"StreetAddress1":"false","City":"false","State":"false","Zip5":"false","Zip4":"false"},"SSN":"false","HomePhone":"false","DOB":{"Year":"false","Month":"false","Day":"false"}},"DOBVerified":"false","NameAddressSSNSummary":"false","NameAddressPhone":{"Summary":"false"},"ComprehensiveVerification":{"ComprehensiveVerificationIndex":"false"},"AdditionalScore1":"false","AdditionalScore2":"false","SSNFoundForLexID":"false","AddressPOBox":"false","AddressCMRA":"false","InstantIDVersion":"false","EmergingId":"false","AddressStandardized":"false","StandardizedInputAddress":{"City":"false","State":"false","Zip5":"false","Zip4":"false"},"BureauDeleted":"false","ITINExpired":"false","IsPhoneCurrent":"false"},"Header":{"Status":0,"TransactionId":"false"},"Pdf":"abc"},"_xmlns":"200"}}}';`

APIResponse layer=new APIResponse ();

APIResponse data=layer.parse(responsebody);

I am getting null whenever I am trying to desearlize the response. Also I'm not able to access value of pdf variable. Please advise.

2
  • if it's null, why are you expecting to be able to access pdf? What's null exactly? your data variable? Please edit your question to be more specific about what you are seeing, because you can't be getting null.
    – Nick C
    Sep 20 at 2:47
  • @Nick . Yes PDF will contains String. Sep 20 at 2:55

1 Answer 1

1

The reason this isn't working is because your responsebody doesn't match up with your class.

Your responsebody has an extra layer to it. It has 2 properties:

  • http_status_code
  • response

Your class doesn't have these.

Either update your class to match your json, or change your json to:

'{"InstantIDResponseEx":{"response":{"Result":{"InputEcho":{"SSN":"false","Name":{"First":"0","Last":"false"},"Address":{"Zip5":"false"},"HomePhone":"false"},"UniqueId":"false","VerifiedInput":{"Name":{"First":"false","Middle":"false","Last":"false"},"Address":{"StreetAddress1":"false","City":"false","State":"false","Zip5":"false","Zip4":"false"},"SSN":"false","HomePhone":"false","DOB":{"Year":"false","Month":"false","Day":"false"}},"DOBVerified":"false","NameAddressSSNSummary":"false","NameAddressPhone":{"Summary":"false"},"ComprehensiveVerification":{"ComprehensiveVerificationIndex":"false"},"AdditionalScore1":"false","AdditionalScore2":"false","SSNFoundForLexID":"false","AddressPOBox":"false","AddressCMRA":"false","InstantIDVersion":"false","EmergingId":"false","AddressStandardized":"false","StandardizedInputAddress":{"City":"false","State":"false","Zip5":"false","Zip4":"false"},"BureauDeleted":"false","ITINExpired":"false","IsPhoneCurrent":"false"},"Header":{"Status":0,"TransactionId":"false"},"Pdf":"abc"},"_xmlns":"200"}}'
3
  • Thanks let me try this. Sep 20 at 2:55
  • I tried below code APIResponse ap=new APIResponse(); APIResponse resp=ap.parse(res2.getbody()); //giving my response values. Can you please tell me how can get PDF vaule which is string value. from this wrapper class. Below code APIResponse.cls_response =resp.cls_response; givine not exist Sep 20 at 3:03
  • Does this answer your actual question of why you're getting null? if so, mark it as correct answer. You might also want to look at: salesforce.stackexchange.com/questions/57459/…
    – Nick C
    Sep 20 at 23:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .