Handlebars Helpers
To JSON String
Serializes values to JSON strings during Handlebars substitution. Useful for API payloads, prompts, logs, and passing structured data between tasks.
Uses
You can use this helper to convert an object, value, or array to a JSON string.
This is helpful when you want to pass some data to an LLM task as a JSON. You can use this inline to convert the data to a JSON string directly in prompts.
TIP
You could use the JSONata hashtag helper to convert the other way, from a JSON string back to an object.
Usage
Helper name : to_json_string
Examples
Example use in task:
Substituted definition
Example of pretty print
OUTPUT
{ "number": 1, "string": "string", "boolean": true, "array": [ 1, 2, 3 ], "obj": { "a": 1 } }