Hacker News new | ask | show | jobs
by svisser 3308 days ago
For those looking to validate dictionaries / JSON responses in Python, the voluptuous library works quite well: http://github.com/alecthomas/voluptuous. It also works for lists and other data types.
2 comments

I 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

JSON has a well defined schema system that works across languages. http://json-schema.org/

Python comes with the jsonschema module out of the box.

What do you mean by 'out of the box'? jsonschema needs to be installed. It's not in the stdlib.
That's rather verbose, though. I prefer the much more functional "schema" library:

https://github.com/keleshev/schema

Thing 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.