tojson
stringConverts a value to a JSON string representation
Syntax
tojson(value) Parameters
value (any) The value to convert to JSON
Returns
string JSON string representation
Examples
Input:
tojson({name: "Alice", age: 30}) Output:
"{\"name\":\"Alice\",\"age\":30}" Input:
tojson([1, 2, 3]) Output:
"[1,2,3]" Input:
{x: 1} | tojson Output:
"{\"x\":1}" The tojson() function converts any value to its JSON string representation. This serializes objects, arrays, and values into valid JSON format.
Usage
Use tojson() for serializing data structures, preparing data for API calls, storing complex objects as strings, or debugging data structures.