fix: encode mixed arrays with inline table elements

Assisted-by: GLM 5.3 Flash
This commit is contained in:
2026-09-17 19:49:50 +02:00
parent 2737a5ac87
commit 3ac0b1e301
5 changed files with 157 additions and 3 deletions
+12
View File
@@ -289,6 +289,18 @@ func (p Port) MarshalTOML() (any, error) {
}
```
### Arrays
An array whose every element is a table (`[]struct`, `[]map[string]V`, after
pointer dereference) emits as an array of tables. TOML also lets one array mix
tables with scalars; such an array emits as a plain value array, with the
table elements rendered as inline tables:
```go
tree, _ := interpres.Parse([]byte(`arr = [1, {a = 2}, "x"]`))
out, _ := interpres.Marshal(tree) // arr = [1, {a = 2}, "x"]
```
### Empty arrays
A nil slice is always omitted. An empty (length 0) array of tables is always