fix: encode mixed arrays with inline table elements
Assisted-by: GLM 5.3 Flash
This commit is contained in:
+12
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user