-
-
Save eddywebs/a1ac7b79fd7f9af6d261 to your computer and use it in GitHub Desktop.
Revisions
-
quintonwall created this gist
Jun 17, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ /** * Example of using JSON serialization to pass complex objects to @future handlers in Apex * $author: [email protected] */ public with sharing class AddressFuture { public AddressFuture () { List<String> addresses = new List<String>(); AddressHelper ah1 = new AddressHelper('1 here st', 'San Francisco', 'CA', '94105'); AddressHelper ah2 = new AddressHelper('2 here st', 'San Francisco', 'CA', '94105'); AddressHelper ah3 = new AddressHelper('3 here st', 'San Francisco', 'CA', '94105'); //serialize my objects addresses.add(JSON.serialize(ah3)); addresses.add(JSON.serialize(ah2)); addresses.add(JSON.serialize(ah3)); doFutureCall(addresses); } @future static void doFutureCall(List<String> addressesSer) { AddressHelper currAddress = null; for (String ser : addressesSer) { currAddress = (AddressHelper) JSON.deserialize(ser, AddressHelper.class); System.debug('Deserialized in future:'+currAddress.street); } } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ /** * Sample encapsulated class * $author: [email protected] */ public with sharing class AddressHelper { public String street {set; get;} public String city {set; get;} public String state {set; get;} public String zip {set; get;} public AddressHelper(String s, String c, String st, String z) { street = s; city = c; state = st; zip = z; } }