Does TOML support top level arrays of dictionaries?
Asked Answered
H

1

11

I am trying to write a configuration file that would be an array (list) or dictionaries (hashes, tables). In JSON terms that would be for instance

[
   {
      "a":1,
      "b":2
   },
   {
      "a":10,
      "b":20
   }
]

I was hoping that

[[]]
a = 1
b = 2

[[]]
a = 10
b = 20

would be correct, but it is rejected by my Go parser with

 unexpected token "]]", was expecting a table array key

This suggests that only top-level dictionaries (hashes, tables) are allowed. Is that really the case?

Hollowell answered 26/5, 2022 at 22:37 Comment(0)
Z
6

TOML 1.0.0 does not permit a top level array.

From github.com/toml-lang/toml:

TOML always has a hash table at the top level of the file, which can easily have data nested inside its keys, but it doesn't permit top-level arrays or floats, so it cannot directly serialize some data.

Zig answered 8/9, 2023 at 1:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.