- Newest
- Most votes
- Most comments
In AWS Step Functions with JSONata, you can use the $string() function to serialize a JSON object into a string, which is the equivalent of the States.JsonToString intrinsic function used in JSONPath.
When using JSONata as your query language in Step Functions, you would format your expression like this:
"Output": "{% $string(yourObject) %}"
For example, if you have a JSON object that you want to convert to a string:
"Output": "{% $string({ \"foo\": \"bar\" }) %}"
This will produce a JSON string representation of the object.
It's worth noting that when you set QueryLanguage to "JSONata" at either the state machine or task level, you'll use the Arguments and Output fields instead of JSONPath fields like InputPath, ResultPath, ResultSelector, and OutputPath.
The JSONata expressions in Step Functions are enclosed in {% %} delimiters, and you have access to more functions and operators compared to JSONPath, though some functionality may differ between the two query languages.
Sources
Transforming data with JSONata in Step Functions - AWS Step Functions
Simplifying developer experience with variables and JSONata in AWS Step Functions | AWS Compute Blog
Relevant content
asked a year ago
asked a year ago
asked 2 years ago
