JSON.ENCODE

JSON.ENCODE encodes a context reference into JSON.

Function category: JSON

This function can only take a context reference (i.e. data.vehicle), which means that passing map literals directly into the function won't work.

To perform the opposite operation, decoding a given JSON, use JSON.DECODE

Syntax

JSON.ENCODE(arg1)

Arguments

Description

arg1

A string.

Example

Let's say we receive the following vehicle information:

{
"data": {
"vehicle": {
"model": "prototype",
"serial_numbers": [
1,
2,
3
]
}
}
}

If we want to pass along that vehicle information as a JSON string, use the following function.

JSON.ENCODE(data.vehicle)

This returns the following:

{
"model": "prototype",
"serial numbers": [
1,
2,
3
]
}