paiden / Nett

.Net library for TOML
MIT License
223 stars 27 forks source link

Support TomlTableArray and jagged TomlArray in Nett.AspNet #76

Closed twaalewijn closed 5 years ago

twaalewijn commented 5 years ago

Fixes #75.

I've based the implementation on matching the output of Microsoft.Extensions.Configuration.Json.

A thing to note is that empty objects/arrays are still counted but of course not added to the final output. This means that the JSON library produces:

{ "tableArray:0:id", "1" },
{ "tableArray:2:id", "2" }

when passed:

{
  "tableArray": [
    {
      "id": 1
    },
    {
    },
    {
      "id": 2
    }
  ]
}

I couldn't find whether that is a bug or not but I assume it isn't since the object is there, it just doesn't have any values. The Binder doesn't seem to care either way.

So going by that assumption, the following TOML produces the above data as well:

[[tableArray]]
id = 1

[[tableArray]]

[[tableArray]]
id = 2
paiden commented 5 years ago

Ah so that's the way how these types can be represented as a provider dictionary.

Very nice and clean PR with everything needed as far as I can tell.

Thank you very much for this fix.

twaalewijn commented 5 years ago

No problem, I'm glad I was able to contribute something back after how easy it was to add TOML configuration support to my programs with this library.

So thank you for creating and maintaining this project and saving me/others development time :+1:.