beetbox/confuse

Thoughts on make confuse compatible with json file?

staftermath opened this issue · 3 comments

Thanks for this project! I found many of the ideas in the implementation brilliant and interesting.

One thought, I understand confuse classifis itself as yaml config parser. In many use cases, we also use json as config file. I did a quick check of the source code, except for a few places where yaml format is required, I think there is a good potential to open it up to natively support json loading?

For example, we could change https://github.com/beetbox/confuse/blob/master/confuse/core.py#L592 a bit to allow a "JSONSource". The main concept of View is dictionary based, which is compatible with json anyway.

I did some quick experimentation and try to inherit some of the classes from confuse and implement a fork to support json. But I still feel that would be a bit forced. Perhaps that extension belongs to confuse itself.

Please let me know what you think.

It could be worth exploring, depending on how complicated the core changes turn out to be! Perhaps this is a silly question, but YAML is designed to be a superset of JSON—so if you have JSON configuration files, could you just use a plain old YAMLSource to parse them anyway?

@sampsyo you are right! Thanks! I did not know yaml can directly load json files. This is great. No changes needed at all :)

Awesome!