Jeffail/gabs

YAML support?

s3rj1k opened this issue · 2 comments

Can I use this library for interacting with dynamic YAML?

Hey @s3rj1k, yes as long as the parsed structure contains map[string]interface{} map types and not map[interface{}]interface{}. If you're using gopkg.in/yaml.v3 then that will be the case unless there are non-string key types within your structure, which often isn't the case. However, earlier versions of gopkg.in/yaml are different in that they always parse map[interface{}]interface{} when provided an empty interface, which won't work with gabs.

Hi @Jeffail !
In order to support yaml.v2 do you think it would be reasonable to add

else if mmap, ok := object.(map[interface{}]interface{}); ok { ... }

in https://github.com/Jeffail/gabs/blob/master/gabs.go#L141
more-less copy-pasting previous block