klyn.io.json.JSON.stringify
method
public static stringify(value as Object, spaces as Boolean = true, pretty as Boolean = false, indent as Int = 0) as String throws JSONWriteException:
Description

Serializes a value as JSON.

Parameters
ParameterDescription
valueValue to serialize, including null.
spacesWhen pretty is false, controls compact spacing.
prettyEnables multi-line formatting.
indentIndentation width when pretty is true. A non-positive value falls back to 4 spaces.
Returns

Serialized JSON text.

Throws
  • JSONWriteException if the value cannot be represented as JSON.
Example
config = {"fullscreen": true, "theme": "dark"}
print(JSON.stringify(config, pretty=true, indent=2))