EncodeOptions
Controls how Python objects are encoded to TOON format.Fields
Number of spaces per indentation level. Common values are
2 or 4.Delimiter used for separating values in primitive and tabular arrays.Available values:
Delimiter.COMMA- Comma delimiter (,)Delimiter.TAB- Tab delimiter (\t)Delimiter.PIPE- Pipe delimiter (|)
Whether to add a
# prefix to array lengths in headers.Whether to collapse nested single-key objects using dot notation.
Maximum depth for key folding. Controls how many levels deep the key folding will go. Only relevant when
key_folding=True.Complete Example
DecodeOptions
Controls how TOON format is decoded to JSON/Python objects.Fields
Whether to format JSON output with indentation and newlines. When
False, produces minified (compact) JSON.Number of spaces per indentation level in JSON output. Only used when
pretty=True.Whether to expand dotted keys (e.g.,
database.connection.host) into nested objects.Per TOON specification §13.4, this option is OFF by default to preserve dotted keys as literal key names.Complete Example
expand_paths=True):
Using Options Together
You can use both encoding and decoding options with theBidirectionalConverter:
Default Values Summary
EncodeOptions Defaults
| Field | Default | Type |
|---|---|---|
indent_size | 2 | int |
delimiter | Delimiter.COMMA | Delimiter |
length_marker | False | bool |
key_folding | False | bool |
flatten_depth | float('inf') | int |
DecodeOptions Defaults
| Field | Default | Type |
|---|---|---|
pretty | True | bool |
indent | 2 | int |
expand_paths | False | bool |