marzer / tomlplusplus

Header-only TOML config file parser and serializer for C++17.
https://marzer.github.io/tomlplusplus/
MIT License
1.47k stars 141 forks source link

What is the proper way to parse top level arrays? Seems not working #223

Closed degloff closed 3 months ago

degloff commented 3 months ago

How can this simple toml file be parsed?

[[elems]]
a = 1
b = 2

[[elems]]
a = 10
b = 20

It should be an array so once parsing the table, tbl["elems"] should be an array or array of tables but it is not.

What is wrong here? I use VS 2022.

Thanks for a hint how to use it properly.

marzer commented 3 months ago

Please use the bug report template. I will close this so you can re-submit with the information requested in the template.

degloff commented 3 months ago

Hm seems to work if I use the cast like this: *tbl.get_as<toml::array>("elems"). Interesting.

degloff commented 3 months ago

Let me dig a bit deeper. And thanks for quick reply.

marzer commented 3 months ago

I suggest you see the Working with TOML data section of the main page for usage examples.