Array Format Selection
TheArrayClassifier class (toon_json_converter.py:195-223) determines which format to use:
- Primitive Array: All elements are primitives (not objects or arrays)
- Tabular Array: All elements are objects with identical keys and primitive values
- List Array: Everything else (mixed types, nested structures, non-uniform objects)
Primitive Arrays
Primitive arrays contain only strings, numbers, booleans, and null values.Syntax
length: Number of elements in the array- Values are separated by the active delimiter (comma by default)
- Values appear on the same line as the header
Examples
Quoting in Primitive Arrays
Strings follow the same quoting rules as regular values:Empty arrays are valid:
empty[0]:Tabular Arrays
Tabular arrays are perfect for arrays of uniform objects - like database query results or CSV data.Syntax
length: Number of rowsdelimiter: Optional marker (space for tab,|for pipe, omitted for comma){field1,field2,...}: Field names (always comma-separated, per §9/§11)- Each row contains values in the same order as fields
Basic Example
Benefits
Compare the space savings:Requirements for Tabular Format
Tabular format is only used when:- Array is non-empty
- All elements are objects
- All objects have the exact same keys
- All values are primitives (no nested objects/arrays)
Delimiter Variants
Comma (Default)
Tab (--tab flag)
Pipe (--pipe flag)
Complex Tabular Example
List Arrays
List arrays handle everything else: mixed types, nested structures, and non-uniform objects.Syntax
- Each item is prefixed with
-(dash-space) - Items are indented one level from the header
- Items can be primitives, objects, or arrays
Simple List
This becomes a list array instead of a primitive array only when manually specified. The converter automatically uses primitive format for simple values.
List of Objects
Mixed Types
Nested Arrays
Complex Nested Example
Array Headers in Different Contexts
Top-Level Array
Named Array in Object
Nested Array in List Item
First entry shares the dash line:Optional: Length Markers
Use--length-marker flag to add # prefix to array lengths:
Field Notation
Field lists in tabular arrays always use comma separators, regardless of the delimiter used for values:This is per §9/§11 of the TOON spec (see
toon_json_converter.py:252-253).Empty Arrays
All formats support empty arrays:Performance Considerations
Space Efficiency
- Primitive arrays: Most compact for simple lists
- Tabular arrays: Excellent for uniform objects (40-60% space savings vs JSON)
- List arrays: Similar to JSON but with cleaner formatting
Parsing Speed
- Primitive arrays: Fastest to parse (single line)
- Tabular arrays: Fast (no repeated key parsing)
- List arrays: Standard parsing speed
Next Steps
Examples
See comprehensive real-world examples
CLI Options
Learn about delimiter and format options