You need to sign in to do that
Don't have an account?
soorya r
How to deserialize JSON response with dynamic data
Hi All,
I am getting the response from third party application by REST API callout. But the response value is coming dynamically ( don't know parameters in response). In response I am getting mapping field which means third party field mapped to Salesforce Field. After that response I will send the salesforce field value to that third party field again based on the response. so that I need to store the response value in wraaper class . So I need to know how to deserialize JSON dynamic response and store the response value in wrapper class. Please help me.
Sample Response 1:
{"column_map":{"account_id":"AccountId","account_name":"Account.Name","contact_name":"Name","phone":"Phone","title":"Title","city":"MailingCity","state":"MailingState","email_id":"Email","crm_id":"Id",
"first_name":"FirstName","last_name":"LastName","record_type":"record_type"},"status":"0"}
Sample Response 2:
{"column_map":{"custom_varchar_6":"Lead_Status__c","custom_varchar_11":"Lead_Source__c","custom_varchar_14":"Lead_3X3__c","custom_varchar_17":"Industry__c","custom_varchar_19":"Notes__c",
"custom_phone_1":"Direct_Phone__c","custom_phone_2":"Mobile__c","custom_varchar_3":"Account_3x3__c","custom_varchar_9":"Competitor__c","custom_varchar_15":"Last_Activity__c","custom_varchar_20":"CL_Call_Attempts__c",
"custom_date_2":"Date__c","account_name":"Company","phone":"Phone","contact_name":"Name","title":"Title","city":"City","state":"State","email_id":"Email","crm_id":"Id","first_name":"FirstName","last_name":"LastName",
"record_type":"record_type"},"status":"0"}
Thanks.
I am getting the response from third party application by REST API callout. But the response value is coming dynamically ( don't know parameters in response). In response I am getting mapping field which means third party field mapped to Salesforce Field. After that response I will send the salesforce field value to that third party field again based on the response. so that I need to store the response value in wraaper class . So I need to know how to deserialize JSON dynamic response and store the response value in wrapper class. Please help me.
Sample Response 1:
{"column_map":{"account_id":"AccountId","account_name":"Account.Name","contact_name":"Name","phone":"Phone","title":"Title","city":"MailingCity","state":"MailingState","email_id":"Email","crm_id":"Id",
"first_name":"FirstName","last_name":"LastName","record_type":"record_type"},"status":"0"}
Sample Response 2:
{"column_map":{"custom_varchar_6":"Lead_Status__c","custom_varchar_11":"Lead_Source__c","custom_varchar_14":"Lead_3X3__c","custom_varchar_17":"Industry__c","custom_varchar_19":"Notes__c",
"custom_phone_1":"Direct_Phone__c","custom_phone_2":"Mobile__c","custom_varchar_3":"Account_3x3__c","custom_varchar_9":"Competitor__c","custom_varchar_15":"Last_Activity__c","custom_varchar_20":"CL_Call_Attempts__c",
"custom_date_2":"Date__c","account_name":"Company","phone":"Phone","contact_name":"Name","title":"Title","city":"City","state":"State","email_id":"Email","crm_id":"Id","first_name":"FirstName","last_name":"LastName",
"record_type":"record_type"},"status":"0"}
Thanks.
Instead what you can do, you can build different Wrapper classes based on the different responses you are supposed to receive and call those classes based on the specific endpoints in the Legacy system.
Regards,
Pankul