During a workflow, you may need to convert data from the context or external sources into a valid JSON object. JSON formatting enables consistent referencing and manipulation across steps.
However, raw data often contains whitespace, newline characters, or quotation marks that can break JSON formatting. These characters must be escaped to safely include the data in a JSON structure while preserving its original content.
Use Output utilities to convert raw data
Handle invalid JSON characters: Raw data may include special characters (such as
\nor"), which can cause JSON parsing to fail.Prevent conversion errors: Attempting to insert unescaped raw data directly into a JSON object (for example, using a JSON Parser step) may result in invalid JSON.
Escape data before insertion: Use the
jsonescapeinline function to safely convert raw data into a JSON-compatible string.
Example:{"data":"{{ jsonEscape $.raw_data.output }}"}
Result: The output becomes a valid JSON object with a single key-value pair.Key:
"data"Value: Escaped string (e.g.,
"\nan \nexample\n")
The original structure of the data is preserved, allowing it to be safely passed to other steps (such as HTTP requests) and reconstructed when needed.




