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
» 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!