I was looking around a lot, not finding what I was looking for. Projects like Marshmallow came close. They allow specification of schemas and provide for serialization, however I wanted the jsonschema format for interoperability.
So I've written my own serializer/deserializer class around a pandas dataframe, which represents the data. It has methods
- for creating a dataframe from a dictionary or json object (deserialization) 2. for coercing data types,
- for inferring a schema,
- for validating the schema, and
- for serialization to json.
Videos
Python JSON REST framework with (de)serialiser and schema validation (jsonschema/avro) - Stack Overflow
python; jsonschema, validate that a schema is valid jsonschema - Stack Overflow
JSON Schema validation
Python: Best Schema-from-JSON-samples generator?
https://github.com/Julian/jsonschema/ is a python module that supports draft03 and draft04.
https://github.com/cwacek/python-jsonschema-objects creates classes from jsonschema, along with loading JSON into them and associated validation. I haven't found a way to give it a list of unrelated schema and emit many classes in one shot, though.
On the interactive web-service end of things, http://jsonschema.net/ does a pretty reasonable job.
More on reddit.com
» pip install jsonschema
I was looking around a lot, not finding what I was looking for. Projects like Marshmallow came close. They allow specification of schemas and provide for serialization, however I wanted the jsonschema format for interoperability.
So I've written my own serializer/deserializer class around a pandas dataframe, which represents the data. It has methods
- for creating a dataframe from a dictionary or json object (deserialization) 2. for coercing data types,
- for inferring a schema,
- for validating the schema, and
- for serialization to json.
It's not very clear what your problem with serialization and deserialization is. Most web frameworks would not treat URL query parameters as a JSON object, but rather treat each key separately and allow you to access the query string as a dictionary (or as arguments to the request handler, depending on framework). Something like request.query['name']. JSON usually appears as the payload for POST, PUT, PATCH and as the response of the request. Even in that case, you get it as a string and do something like json.loads to obtain Python data structures, which you're then free to validate with a json-schema or avro validator library.
That's precisely how schemas are validated! Download the meta-schema (declared in the $schema keyword) and validate the schema against the meta-schema. It's designed to do this.
The API to validate a schema itself is SomeValidator.check_schema.
Please let me know (by filing an issue) if there's anything in the documentation that would have helped you find it easier!