var.toString
string toString() const @safeConvert the stored value to a human-readable string.
Formatting rules:
- Scalars use
std.conv.toformatting (e.g.,1,true). Type.STRINGreturns the raw string (no quotes) at the top level.Type.ARRAYandType.OBJECTare rendered in a compact, JSON-like form:- Arrays:
[elem1,elem2,...](elements are recursively formatted; strings are quoted with escapes). - Maps:
{"key":value,...}with keys sorted lexicographically for deterministic output. - A recursion guard is applied to avoid runaway printing; deeply nested content may be replaced with
null.
Floating-point values are formatted for display: std.conv.to's default six significant digits can discard stored digits (for example var(1.2345678901234567).toString() is "1.23457"). This output is not a persistence format. Use toStringRoundTrip for shortest text that parses back to the exact stored value, or the JSON writer for serialization. Legacy display output is intentionally unchanged.