function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Anil SavaliyaAnil Savaliya 

How get value from JSON string and insert ?

Hello

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?
Ramu_SFDCRamu_SFDC
You need to use JSON parser class methods to do this. Please review the below blog post that has an example on the same

http://www.tgerm.com/2011/10/winter12-jsonparser-serialize.html

Below is the salesforce documentation on JSON Parsing

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_json_jsonparser.htm
http://www.salesforce.com/us/developer/docs/dbcom_apex250/Content/apex_methods_system_jsonparser.htm