libcyaml
libcyaml copied to clipboard
Ability to load YAML map into hash table
It seems this library is limited to loading only structured maps into specific C structs with known (static) keys and types. It would be useful to allow a map with unknown (dynamic) keys to be loaded into a runtime hash table data structure. Or at the very least provide an example of how to escape the libcyaml binding mechanism and be able to work at the libyaml level for a specific schema.
I've been thinking about this. It kind of goes against the core principal of the library, which is that it simply slots data into client-defined data structures.
I was assuming that anything that required loading data who's structure wasn't known up-front would be done better by using libyaml directly.
On the other hand, I've considered a CYAML_CUSTOM value type, which would need a callback function, and the client would get to handle the libyaml events. However, I don't like exposing a libyaml API requirement through libcyaml's API.
Anyway, thanks for the feedback/request. I need to think about it some more!
The problem is then that libcyaml becomes useless if I want to use it for the majority of my use cases but I have this one bit of yaml that requires that I parse it into a hash table. I think the CYAML_CUSTOM value would be very useful and offers that escape hatch. Usage of libcyaml requires linking in libyaml anyway so there's no shame in exposing some libyaml APIs or data structures via libcyaml, unless you were planning on uprooting your implementation to use some other low-level yaml parsing library.
@tlsa Is it now supported to load YAML map into hash table ?
@XisonChen No, it's not currently supported.