klyn.io.json.JSON.stringify
method
public static stringify(filename as String, 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 file named by a string.

Parameters
ParameterDescription
filenameDestination filename.
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 file.

Throws
  • JSONWriteException if the value cannot be represented as JSON.
  • IOException if the file cannot be written.
Example
JSON.stringify("settings.json", {"theme": "dark"})