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

- exclude Optional list of member names to exclude.
- spaces Controls compact spacing when `pretty` is false.
- pretty Enables multi-line formatting.
- indent Indentation size. When `pretty` is true and `indent` is 0, a default indentation of 4 spaces is used.

Returns

JSON representation of the object. ```klyn import klyn.math r = Rational(3, 4) print(r.toJson(pretty=true, indent=2))` ``