mayah / tinytoml

A header only C++11 library for parsing TOML
BSD 2-Clause "Simplified" License
167 stars 31 forks source link

invalid output for 2-dimensional array of table #53

Open momentarylapse opened 7 months ago

momentarylapse commented 7 months ago

Hi, I'm getting some weird output when trying to write 2-dimensional arrays with objects/tables inside. I'm trying to save the equivalent of JSON {"A": [ [ {"value": 1} ] ] }.

My code:

toml::Value base;
toml::Array outer;
toml::Array inner;
toml::Value object;
object["value"] = 1;
inner.push_back(object);
outer.push_back(inner);
base["A"] = outer;

base.write(&std::cout);

The code produces:

A = [[value = 1
]]

and toml::parse() flags this as invalid.

Could the curly braces be missing for a correct inline table? I.e.

A = [[{value = 1}]]

Or is there something I should do differently in the code?

Thanks, Michael