Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
encoding/toml: implement support for table arrays
This is a significant amount of code given that there are effectively three ways in which table arrays can be used. First, declaring a new array and repeating its key like: [[foo]] leaf = "one" [[foo]] leaf = "two" resulting in appending to the same array: foo: [ {leaf: "one"}, {leaf: "two"}, ] Second, a table array can be created under an existing table: [foo] leaf = "one" [[foo.bar]] leaf = "two" resulting in: foo: { leaf: "one" bar: [ {leaf: "two"}, ] } Third, and perhaps most confusing, a table or table array can be created under an existing table array, adding to the table's last element: [[foo]] leaf = "one" [foo.bar] leaf = "two" [[foo.baz]] leaf = "three" resulting in: foo: [ { leaf: "one" bar: { leaf: "two" } baz: [ {leaf: "three"} ] }, } We add test cases for all of these edge cases, as well as test cases to ensure that unique keys are handled correctly, and that we reject declaring a key as both a table and an array table. Updates #68. Signed-off-by: Daniel Martí <[email protected]> Change-Id: I2b483a67810b7c42ddf319a04a0f22724877b8a9
- Loading branch information