Serialize Records to JSON and Deserialize JSON strings to Records
Neil Armstrong, a Flow ace in the Salesforce solution engineering corps, came by with a use case:
I’m working on a Lambda function that can invoke flows via REST. Is there a way to pass in records? The REST API for Flow only accepts strings
As Neil points out,the REST interface only supports string inputs. But you can solve problems like this by passing the object in as a string to the Flow and then using a Flow Action to deserialize (convert) the string to your desired SObject.
This is something that has been available for a long time via custom code, but the recent support that Flow gained for dynamic sobjects makes it possible to package this functionality as an installable pair of actions, provided below.
Serialize SObject To Json
This action has the following inputs:
inputSObject | This can be any record. You specify the object type in Flow Builder each time you add an instance of this action to a Flow. |
inputSObjectList | This can be any record collection |
This action outputs a serialized string representing the record. For example, a basic Account generates this JSON:

Deserialize JSON to SObject
This action takes as input:
serializedSObjectListString | this expects a string like the one shown above. |
objectTypeName | this expects a string formatted as a json array, with one or more interior records |
This action outputs:
outputSObject | |
outputSObjectList |
Here’s a demo flow that uses both of these. It loads an Account, serializes it to a string, and then converts it back to an account. This flow is available in the package and will run as long as your org has an account with name ‘account1’.

Considerations
You may notice that Account is specified three different times: two visible above and one inside the serialized string. That’s deeply inefficient, but 1) I haven’t quite figured out how to introspect the type that the user selects in the “Object for” field and 2) I don’t have time at the moment to build properly robust json parsing to pull it out of the string. These are left as exercises for people who want to become famous.
One possible use case for this: you can serialize a record and then store it in a string field of another record! And then later on, you can retrieve that string and deserialize it back to a record! I have no idea if that’s useful, but it smells like it could be. Anyone have any other ideas for what one might do with serialization and records in flows?
Install
Unlocked 1.1.0 9-22-21
Old Versions