You need to sign in to do that
Don't have an account?

Adding an Array within Map for JSON payload
I am trying to send a record to an external system via Async service . Only one value within that payload needs to be an array while the remaining should be string. Does any one know how it can be done?
searlization looks like below..
While the output that I am seeking is like..
That is a LONG TEXT field in UI and will hold multiple urls separated by comma or semi-colon.
searlization looks like below..
Map<String, String> data = new Map<String, String>{ 'email' => acc.Email__c, 'displayName' => acc.Display_Name__c, 'bioUrl' => acc.Bio_URL__c, 'imageUrl' => acc.Image_URL__c, 'vertical' => acc.Channel__c, 'status' => acc.Status__c, 'gid' => acc.Legacy_GID__c, 'numberOfExperts' => String.valueOf(acc.Number_of_Experts__c), 'userId' => String.valueOf(acc.Selene_ID__c), 'socialPreference' => acc.Social_Presence__c }; String jsonInput = JSON.serializePretty(data, True);
While the output that I am seeking is like..
{ "socialPreference" : [ "www.facebook.com/101", "www.twitter.com/101" ], "userId" : "123456789123", "numberOfExperts" : "1", "gid" : "210967", "status" : "LIVE", "vertical" : "SALESFORCE", "imageUrl" : "", "bioUrl" : "", "displayName" : "test101", "email" : "test101@test.com" }I don't know how to convert just one value (socialPresence)into an array format.
That is a LONG TEXT field in UI and will hold multiple urls separated by comma or semi-colon.
you can try like this: As for testing purpose i have added ArrayPreferences and get as expected Plz let me if it helps you.
Thanks
Niraj
All Answers
you can try like this: As for testing purpose i have added ArrayPreferences and get as expected Plz let me if it helps you.
Thanks
Niraj
I did separate out values in different fields .. abc.com in one field and xyz.com in another and then just combined them in list.
But your approach is brilliant.
Thanks Niraj.
Really appreciate the assist.