Object.to_string
Object.to_string
Function
Serialize the object into a JSON string.
Syntax
object.to_string(mode)
Parameters
| Parameters | Type | Required | Default value | Description |
|---|---|---|---|---|
| mode | String | No | None | Returns the indentation format when passing in JSON_PRETTY. |
Return value
| Type | Description |
|---|---|
| String | Returns the object JSON string. |
Example
user = {name: 'BT', age: 1} result = user.to_string() // Output: {"name":"BT","age":1} print result
Notes
- Normal mode outputs compact JSON.
- JSON_PRETTY is a system constant whose value is the string JSON_PRETTY.