public toJson(exclude as List<String> = null, spaces as Boolean = true, pretty as Boolean = false, indent as Int = 0) as String:
Returns the object as JSON text.
Compact output is produced by default. Pretty output uses an indented multi-line format delegated to JSON.stringify(...).
| Parameter | Description |
|---|---|
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. |
JSON representation of the object.
import klyn.math r = Rational(3, 4) print(r.toJson(pretty=true, indent=2))