All TOON arrays must include a length indicator [N] for validation. There are three primary array formats depending on the data type:
1. Primitive Arrays
Used for arrays of simple values (numbers, strings, booleans). They use an inline comma-separated format. The comma delimiter is hidden in the header.
[5]: 1,2,3,4,5
[3]: alpha,beta,gamma
2. Tabular Arrays
Used for uniform arrays where every object has the same keys and all values are primitives. This uses a CSV-like format for maximum efficiency.
- All objects must have identical keys.
- All values must be primitives (no nesting).
- The header includes the keys:
[N,]{key1,key2}.
[3,]{id,name,age}:
1,Alice,30
2,Bob,25
3,Charlie,35
3. List Arrays
Used for non-uniform or nested arrays (where elements might be different types or contain objects/arrays). These use a - marker for each element.
[3]:
- name: Alice
- 42
- hello
4. Nested and Empty Arrays
- Nested: Arrays within arrays use the list format or primitive format recursively.
- Empty: Represented by
[0]:.
matrix[2]:
- [3]: 1,2,3
- [3]: 4,5,6
items[0]:
[3,]{id,name,age}:
1,Alice,30
2,Bob,25
3,Charlie,35