Contents · Forum Home · StreamSec Tools 4.1.5.363 documentation

methodtJsonValue.ToJson

function ToJson(aSorted: Boolean = False; aIndent: Integer = 0): string;
ToJson writes the value with no insignificant whitespace. With aSorted, every object's members are emitted in ascending order of name, compared by code unit - the canonical form RFC 7638 hashes.

aIndent is the fine print: 0, the default, is the compact form above; a positive value indents each nesting level by that many spaces, puts every array element and object member on its own line, and writes one space after each member's colon. An empty object or array still writes as {} or [] on one line.

Line breaks are LF, on every platform, so a document written here is byte-identical wherever it was produced - which matters as soon as anything hashes or signs it.

aIndent AND aSorted ARE NOT MEANT TO BE COMBINED. Sorting exists to produce the canonical form for a thumbprint or a signature, and that form is defined to have no insignificant whitespace; indenting it yields something that is neither canonical nor a thumbprint input. Use aIndent for documents meant to be read, aSorted for bytes meant to be hashed.