{"id":9848,"library":"jschon","title":"jschon: A JSON Toolkit for Python Developers","description":"jschon is a comprehensive Python library for working with JSON data, JSON Schema validation (supporting Draft 2020-12), JSON Pointer, JSON Patch, and JSONPath. It provides robust tools for schema definition, data validation, and JSON document manipulation. The current version is 0.11.1, and the library maintains a relatively active release cadence with frequent minor and patch updates.","status":"active","version":"0.11.1","language":"en","source_language":"en","source_url":"https://github.com/marksparkza/jschon","tags":["JSON","JSON Schema","Validation","URI","JSON Pointer","JSONPath","JSON Patch"],"install":[{"cmd":"pip install jschon","lang":"bash","label":"Install base library"},{"cmd":"pip install jschon[uri]","lang":"bash","label":"Install with URI reference support"},{"cmd":"pip install jschon[graphql]","lang":"bash","label":"Install with GraphQL support"}],"dependencies":[],"imports":[{"symbol":"JSON","correct":"from jschon import JSON"},{"symbol":"JSONSchema","correct":"from jschon import JSONSchema"},{"symbol":"URI","correct":"from jschon import URI"},{"symbol":"JSONPointer","correct":"from jschon import JSONPointer"},{"symbol":"Catalog","correct":"from jschon import Catalog"}],"quickstart":{"code":"from jschon import JSON, JSONSchema\n\n# Define a JSON Schema\nschema_data = {\n    \"type\": \"object\",\n    \"properties\": {\n        \"name\": {\"type\": \"string\"},\n        \"age\": {\"type\": \"integer\", \"minimum\": 0}\n    },\n    \"required\": [\"name\", \"age\"]\n}\nschema = JSONSchema(schema_data)\n\n# Define a JSON instance\ninstance_data = {\"name\": \"Alice\", \"age\": 30}\ninstance = JSON(instance_data)\n\n# Validate the instance against the schema\nresult = schema.evaluate(instance)\n\nif result.valid:\n    print(\"JSON instance is valid!\")\nelse:\n    print(\"JSON instance is invalid:\")\n    print(result.output('basic'))\n\n# Example of invalid data\ninvalid_instance_data = {\"name\": \"Bob\", \"age\": -5}\ninvalid_instance = JSON(invalid_instance_data)\ninvalid_result = schema.evaluate(invalid_instance)\n\nif not invalid_result.valid:\n    print(\"\\nInvalid instance output:\")\n    print(invalid_result.output('basic'))","lang":"python","description":"This quickstart demonstrates how to define a JSON Schema, create a JSON data instance, and validate the instance against the schema using `jschon`'s `JSONSchema` and `JSON` classes."},"warnings":[{"fix":"Update calls to `Catalog.get_schema()` to explicitly pass `recursive=False` (or `True`) and `session=None` (or a valid `SchemaSession` object).","message":"The `Catalog.get_schema()` method signature changed. It now requires `recursive` and `session` arguments, which were previously implicit or handled differently.","severity":"breaking","affected_versions":">=0.10.0"},{"fix":"Ensure `JSONPointer` is initialized with a `jschon.URI` object. Convert strings to `URI(your_string)` first if necessary.","message":"The `JSONPointer` constructor now strictly requires a `jschon.URI` object as its base argument, rather than a `jschon.JSON` instance or a string. If a `JSON` instance is provided, its `JSON.uri` attribute is extracted internally.","severity":"breaking","affected_versions":">=0.10.0"},{"fix":"Directly use the `JSONSchema` object returned by `Catalog.get_schema()`. Do not rely on `JSON.schema` for schema access.","message":"The `Catalog.get_schema()` method now returns a `JSONSchema` instance instead of a raw `JSON` instance. The `JSON.schema` attribute was deprecated and now returns `None`.","severity":"breaking","affected_versions":">=0.9.0"},{"fix":"Always wrap URI strings with `jschon.URI()` before passing them to methods or constructors that expect a URI object.","message":"jschon extensively uses `jschon.URI` objects instead of plain Python strings for all URI-related parameters (e.g., `$id`, `$ref`, base URIs). Passing strings where `URI` objects are expected will lead to `TypeError`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Wrap the string with `jschon.URI()` before passing it. E.g., `schema = JSONSchema(schema_data, uri=URI('https://example.com/schema'))`.","cause":"Attempting to pass a plain Python string where a `jschon.URI` object is expected, typically in methods dealing with schema URIs or JSONPointers.","error":"TypeError: object of type 'str' has no len()"},{"fix":"Retrieve schemas directly from the `Catalog` using `Catalog.get_schema()` which now returns a `JSONSchema` object directly.","cause":"Attempting to access the `schema` attribute on a `jschon.JSON` instance, which was deprecated in `v0.9.0`.","error":"AttributeError: 'JSON' object has no attribute 'schema'"},{"fix":"Update your call to `Catalog.get_schema()` to include these arguments, e.g., `catalog.get_schema(URI('https://example.com/schema'), recursive=False, session=None)`.","cause":"Calling `Catalog.get_schema()` without the newly required `recursive` and `session` arguments introduced in `v0.10.0`.","error":"TypeError: get_schema() missing 2 required positional arguments: 'recursive', and 'session'"}]}