I had a requirement to process and validate large payloads of JSON concurrently for a web service, initially I implemented it using jsonschema and fastjsonschema but I found the whole JSON Schema Specification to be confusing at times and on top of that wanted better performance. Albeit there are ways to compile/cache the schema, I wanted to move away from the schema specification so I wrote a validation library inspired by the design of tiangolo/sqlmodel (type hints) to solve this problem easier.
Here is a simple example:
from okjson import JSONValidator
schema = { 'name': str, 'age': int }
json_string = '{ "name": "Charly Gordon", "age": 32 }'
assert JSONValidator().is_valid(instance=json_string, schema=schema)There is an example covering all the features in the README.
It also has well defined exceptions for each error case when you want to get the reason for the validation failure. (Helpful when you want to show user facing error messages)
GitHub: https://github.com/mufeedvh/okjson
This is my first time publishing a Python library, please share your feedback/suggestions. :)
multi agent - Generate a JSON Schema specification from Python classes - Stack Overflow
How I Learned to Stop Worrying and Love JSON Schema
Pretty convincing. I'll give it a try sometime.
More on reddit.comMost secure json schema validation for node?
JSON Schema Validator 0.1a for Python
Meh, something about JSON schemas in JSON doesn't look pretty enough for me...
More on reddit.comVideos
» pip install jsonschema