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
Alexandre DinnoutiAlexandre Dinnouti 

Saving SOQL results as json in AWS S3

Hi !

Is there a tool out there to save SOQL query results as JSON in AWS S3? We are planning to write a system to cache SOQL query results using SalesForce API, before start coding I would like to know if such solution already exists.

thanks,
Alex.
AjazAjaz
Hey Alex,

you can use standard JSON method serializepretty like below.

ˇserializePretty(objectToSerialize)
Serializes Apex objects into JSON content and generates indented content using the pretty-print format.

Lets say you got your SOQL result in the list accountList object. Pass this list as a parameter to serializePretty method like below.

List<Account> accountList = [SOQL QUERY];
String jsonResult = JSON.serializePretty(accountList);

Please give a thumbsup if this helps you.

Regards,
Zaja.