Can't parse HashMap
this is an example of toml
[tasks.a]
cmd = "echo 123"
[tasks.b]
cmd = "echo 123"
I need a possible way to parse this tasks, I can't predict the keys
Thank you
This is a good point!
Arbitrary HashMaps are not supported yet, e.g. HashMap(string, MyValueType...). I do not know yet how to map toml.Value to any possible MyValueType. I'm open to suggestions.
I have just pushed a commit that enables structs to have a field of type toml.Table. Here is an example from the tests.
I was researching how the json parser works and I really liked the approach how it was done in the kernel here you can find an example of how to use https://github.com/ziglang/zig/blob/master/lib/std/json/hashmap_test.zig
and here is exactly how it checks what the hashmap should be https://github.com/ziglang/zig/blob/master/lib/std/json/static.zig#L321-L323
the main idea is that it checks whether the structure has a key function (jsonParse) and if so, simply passes it the parameters
I'm not one hundred percent sure yet, but with a quick glance, it seemed that if you wrote your own scanner, and you can pass it to json functions and most of the code from this library will simply disappear
Anyway, thank you for the quick fix
Thanks for pointing me to the "official" json parser. 👍 I see they changed quite a bit. I will look into.
Finally implemented.
@sirenkovladd Thanks again for the helpful links! The implementation was simpler than I initially thought.