5 ms·
For those looking to validate dictionaries / JSON responses in Python, the voluptuous library works quite well: http://github.com/alecthomas/voluptuous http://g
by svisser 9y ago
For those looking to validate dictionaries / JSON responses in Python, the voluptuous library works quite well: http://github.com/alecthomas/voluptuous http://github.com/alecthomas/voluptuous. It also works for lists and other data types.
- user5994461 9y agoJSON has a well defined schema system that works across languages. http://json-schema.org/ http://json-schema.org/ Python comes with the jsonschema module out of the box.
- StavrosK 9y agoThat's rather verbose, though. I prefer the much more functional "schema" library: https://github.com/keleshev/schema https://github.com/keleshev/schema
- ris 9y agoThing is, none of these are language agnostic. jsonschema is the only one that makes an attempt at that. It's a slight pity that the python jsonschema package doesn't support some of the more powerful recent features though.
- calvins 9y agoWhat do you mean by 'out of the box'? jsonschema needs to be installed. It's not in the stdlib.
- Varriount 9y agoI use a fork/successor library, good[0], for configuration validation. I've especially liked the data transformation it can do (I can easily allow a configuration entry to be a single value, or list of values, and transform that to always be a list) [0] https://github.com/kolypto/py-good https://github.com/kolypto/py-good