Convert to JSON string
Syntax
$input.toJson()
Description
Converts a map or another supported data structure into a JSON-formatted text. The generated JSON string can be converted back into the original data structure using the parseJson() function.
Parameters
| name | Type | Type Description | Mandatory | Default |
|---|---|---|---|---|
| input | Map/list/string/number/truth value | The data structure to be converted into a JSON string. | Yes | - |
Return value
Type: String
A character string that represents the input data structure in JSON format.
Examples
Example 1: Output
person = {"name": "Anna", "alter": 42, "aktiv": true};
$person.toJson()
Output: {"name":"Anna","alter":42,"aktiv":true}
The map is converted into a JSON string. Keys and string values are enclosed in double quotation marks, while numbers and truth values are displayed without quotation marks.$person