ads

Sunday, 23 June 2019

convert sObject to JSON String and JSON string to sObject using apex in Salesforce

Sample Code:

Account acc = new Account(Name = 'TestAccountName', AccountNumber = '234567', Industry= 'IT');

/* Code to convert Account to test string */

String strTest = 
Test .serialize(Acc);
system.debug('
Test String is ' + strTest );

/* Code to convert Test string to Account */

Account Acc1 = (Account)Test .deserialize(str Test , Account.Class);
system.debug('Account is ' + Acc1);

No comments:

Post a Comment