Skip to main content

JsonVL

GitHub CI codecov

JsonVL is a JSON validator for Python. This project is intended to be a replacement for the jsonschema package which implements the JSON Schema standard. JsonVL's goal is to curate a rich set of validation methods for JSON data types while remaining extensible to new constraints.

Installation

Install the latest PyPI release:

pip install jsonvl

Usage

Validate JSON files from the command line

jsonvl data.json schema.json

Validate JSON files in Python

from jsonvl import validate_file

validate_file('data.json', 'schema.json')

Validate in-memory JSON data in Python

from jsonvl import validate

validate(data, schema)

Documentation

The JsonVL documentation is hosted by Read the Docs and is a work in progress.

Example

Below is an example pair of JSON data and JSON schema. More examples can be found in the examples folder.

Data

{
  "play": "A Midsummer Night's Dream",
  "characters": [
    { "name": "Helena", "loves": ["Demitrius"] },
    { "name": "Demitrius", "loves": ["Hermia", "Helena"] },
    { "name": "Hermia", "loves": ["Lysander"] },
    { "name": "Lysander", "loves": ["Hermia", "Helena", "Hermia"] },
    { "name": "Titania", "loves": ["Oberon", "Bottom", "Oberon"] },
    { "name": "Oberon", "loves": ["Titania"] },
    { "name": "Bottom", "loves": [] },
    { "name": "Puck", "loves": [] }
  ]
}

Schema

{
  "type": "object",
  "attr": {
    "play": "string",
    "characters": {
      "type": "array",
      "cons": {
        "unique": "@all.name"
      },
      "elem": {
        "type": "object",
        "attr": {
          "name": "#name",
          "loves": {
            "type": "array",
            "elem": "#name",
            "cons": { "max_size": 4 }
          }
        }
      }
    }
  },
  "defs": {
    "#name": {
      "type": "string",
      "cons": {
        "format": { "type": "regex", "pattern": "[A-Z][a-z]{0,10}" }
      }
    }
  }
}

Metadata

Release files for jsonvl 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jsonvl 0.5.0
File Size Uploaded
jsonvl-0.5.0.tar.gz 18.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jsonvl 0.5.0
File Interpreter ABI Platform
jsonvl-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 47.0 kB

Release files / jsonvl-0.5.0.tar.gz

Download URL jsonvl-0.5.0.tar.gz
Size 18.7 kB
Tags Source
SHA-256 checksum
How to use checksums
efd755aa3f8b85d63c0415cdd2a49f8438bf30c83f33fe1e8367214221636c70
BLAKE2b-256 checksum
How to use checksums
94190a3ef4d4390e7fbbbecbd8d28fd6d5f69362e6415ce7ab3cd5bb64a8edc5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.5

Release files / jsonvl-0.5.0-py3-none-any.whl

Download URL jsonvl-0.5.0-py3-none-any.whl
Size 28.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
17fd296cae13a35c172a89c15b1497958f9fb32827830af9f0ce8a11abc490bd
BLAKE2b-256 checksum
How to use checksums
b3c5fcb8e5c93d41a9e65eb6e0d241b3017dd93d532a498f89dc2551d86a94ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.5

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page