The canonical form of a value (DXN.md §1.5): one .dxn rendering,
fixed down to the byte, so that values from different implementations
can be compared as text.
Dextrin.Canonical.print(%{b: 2, a: 1, "z" => 3})
#=> {:ok, ~s(%{"z" => 3 a: 1 b: 2})}Not Dextrin.encode/2. The ordinary printer chooses what reads
best; this one chooses nothing. One space between items, maps and
sets in canonical order (by code point of each canonical form), floats
by one exact algorithm, strings with one fixed set of escapes — the
same rules every DXN implementation follows, which is what lets the
Dextrin Conformance Suite compare two strings instead of two values.
Keyed structs and ordered maps keep the order they hold: in a
%schema body the order of entries is the order of the fields.
Summary
Functions
The canonical form of value, or an encode/unsupported error for a
value with no DXN meaning.
Functions
@spec print(term()) :: {:ok, String.t()} | {:error, Dextrin.Error.t()}
The canonical form of value, or an encode/unsupported error for a
value with no DXN meaning.