+ Start a Discussion
Anil SavaliyaAnil Savaliya 

How get value from JSON string and insert ?


I getting response in JSON body like
String JS = '[{"User": "12345","Statuses": [{ "EntityId": 123, "Status": "Success" },{ "EntityId": 456, "Status": "Fail" }]},{"User": "67891","Statuses": [{ "EntityId": 345, "Status": "InvalidEntity" },{ "EntityId": 456, "Status": "Success" },{ "EntityId": 456, "Status": "Fail" }]}]';

and I have custom object exception_c and it's two custom field ExceptionUser__c and ExceptionEntityId__c

How can i write logic for exception record insert in case only status fail ?
If status fail insert exception record associate user and entityId assosiate with failer responce?
You need to use JSON parser class methods to do this. Please review the below blog post that has an example on the same


Below is the salesforce documentation on JSON Parsing