pub struct Config {
pub delimiter: u8,
pub key_folding: bool,
pub flatten_depth: Option<usize>,
pub empty_array_bare: bool,
pub escape_controls: bool,
pub max_depth: usize,
pub max_input_bytes: usize,
}Expand description
Encoder configuration. The spec’s only encoder options are delimiter and
indentSize (§13); the rest are etoon extensions or resource guards.
Fields§
§delimiter: u8Delimiter between array/tabular values. Must be ,, \t, or |.
key_folding: boolIf true, fold single-key object chains into dot-notation keys (safe mode). An etoon extension: the spec removed key folding in v4.0, so nothing re-nests the output.
flatten_depth: Option<usize>Max fold depth (segments). None = unlimited. 0 disables folding.
empty_array_bare: boolIf true, emit empty arrays as canonical [] / key: [] instead of the
legacy [0]: / key[0]: length-marker form. False emits output the
spec has forbidden since v3.1.
escape_controls: boolIf true, escape control chars U+0000–U+001F (except the named \n \r
\t) as \uXXXX with lowercase hex. False emits output the spec has
forbidden since v3.1.
max_depth: usizeMax JSON nesting depth. Input deeper than this is rejected before parsing, so neither the sonic-rs DOM parser nor the recursive emitter can overflow the stack (both crash the host process near depth ~50k). 0 disables the check — use only when the input’s depth is already bounded by the producer (e.g. orjson output, capped by CPython’s recursion limit), since the pre-scan is then redundant.
max_input_bytes: usizeMax input size in bytes. 0 disables the check (default). A caller that encodes untrusted input can set this to bound peak memory.