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

Serializes a value and writes it to a path.

Parameters
ParameterDescription
pathDestination path.
valueValue to serialize, including null.
spacesWhen pretty is false, controls compact spacing.
prettyEnables multi-line formatting.
indentIndentation width when pretty is true.
Returns

The JSON text written to the path.

Throws
  • JSONWriteException if the value cannot be represented as JSON.
  • IOException if the path cannot be written.
Example
path = FilePath("settings.json")
JSON.stringify(path, null)