klyn.Object.toJson
method
public toJson(exclude as List<String> = null, spaces as Boolean = true, pretty as Boolean = false, indent as Int = 0) as String:
Description

Returns the object as JSON text.

Compact output is produced by default. Pretty output uses an indented multi-line format delegated to JSON.stringify(...).

Parameters
ParameterDescription
excludeOptional list of member names to exclude.
spacesControls compact spacing when pretty is false.
prettyEnables multi-line formatting.
indentIndentation size. When pretty is true and indent is 0, a default indentation of 4 spaces is used.
Returns

JSON representation of the object.

Example
import klyn.math

r = Rational(3, 4)
print(r.toJson(pretty=true, indent=2))