jsonschema
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
jsonschema | 0.1.9 | FEAT | MIT | Rust |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 2760 | jsonschema | No | Yes | No | Yes | No | Yes | - |
| Related | pgbson pgjq jsquery pg_jsonschema pg_projection jsonb_plperl documentdb jsonb_plperlu jsonb_plpython3u mongo_fdw |
|---|
Distinct from Supabase pg_jsonschema.
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 0.1.9 | 1817161514 | jsonschema | - |
| RPM | PIGSTY | 0.1.9 | 1817161514 | jsonschema_$v | - |
| DEB | PIGSTY | 0.1.9 | 1817161514 | postgresql-$v-jsonschema | - |
Build
You can build the RPM / DEB packages for jsonschema using pig build:
Install
You can install jsonschema directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
Install the extension using pig or apt/yum/dnf:
Create Extension:
Usage
Sources:
jsonschema validates JSON and JSONB values against JSON Schema inside PostgreSQL. It is the theory/pg-jsonschema-boon extension and is distinct from Supabase pg_jsonschema, although it provides compatibility wrappers named json_matches_schema() and jsonb_matches_schema().
The extension supports JSON Schema draft 4, draft 6, draft 7, draft 2019-09, and draft 2020-12 through the Rust boon validator. It has no runtime dependency beyond PostgreSQL.
Latest-check note: upstream main currently points at the same commit as tag v0.1.9, so this refresh found no material user-facing delta beyond replacing the stale generated-SQL source link.
Validate a Schema and a Document
jsonschema_is_valid(schema) returns whether the schema itself compiles and validates against the selected draft. jsonschema_validates(data, schema) returns whether the JSON/JSONB value satisfies the schema.
Check Constraints
Use constraints when the database should reject malformed JSON documents at write time.
Composed Schemas
The id overloads let multiple schemas reference each other by $id, which is useful for componentized JSON Schema definitions.
Compatibility Functions
These wrappers mirror the common pg_jsonschema argument order: schema first, instance second.
Draft Selection and Caveats
If a schema omits $schema, jsonschema.default_draft controls the default draft. Supported values are V4, V6, V7, V2019, and V2020.
jsonschema_validates(data, schema)returns NULL if either argument is NULL.- Invalid or uncompilable schemas can raise errors in validation calls; failed document validation returns
falseand logs details atINFO. jsonschema_is_valid(id, VARIADIC schemas)andjsonschema_validates(data, id, VARIADIC schemas)require matching$idvalues for reliable composed-schema resolution.
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)