mirror of
https://github.com/voson-wang/toon.git
synced 2026-01-29 23:34:10 +08:00
fix: implement nested array indentation
This commit is contained in:
27
README.md
27
README.md
@@ -335,6 +335,30 @@ items[2]{sku,qty,price}:
|
||||
B2,1,14.5
|
||||
```
|
||||
|
||||
**Tabular formatting applies recursively:** nested arrays of objects (whether as object properties or inside list items) also use tabular format if they meet the same requirements.
|
||||
|
||||
```ts
|
||||
encode({
|
||||
items: [
|
||||
{
|
||||
users: [
|
||||
{ id: 1, name: 'Ada' },
|
||||
{ id: 2, name: 'Bob' }
|
||||
],
|
||||
status: 'active'
|
||||
}
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
```
|
||||
items[1]:
|
||||
- users[2]{id,name}:
|
||||
1,Ada
|
||||
2,Bob
|
||||
status: active
|
||||
```
|
||||
|
||||
#### Mixed and Non-Uniform Arrays
|
||||
|
||||
Arrays that don't meet the tabular requirements use list format:
|
||||
@@ -357,6 +381,9 @@ items[2]:
|
||||
extra: true
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
> **Nested array indentation:** When the first field of a list item is an array (primitive, tabular, or nested), its contents are indented two spaces under the header line, and subsequent fields of the same object appear at that same indentation level. This remains unambiguous because list items begin with `"- "`, tabular arrays declare a fixed row count in their header, and object fields contain `":"`.
|
||||
|
||||
#### Arrays of Arrays
|
||||
|
||||
When you have arrays containing primitive inner arrays:
|
||||
|
||||
Reference in New Issue
Block a user