Skip to main content

Part of the Using JSON Schema project.

jsonvalidate is a command line and library utility allowing JSON content to be validated using JSON Schema content from local or remote sources, and use of custom schema storage and URI access.

The utility uses the jsonschema library for the schema validation processing (GitHub repo).

For command line/script use, a console message is displayed and the process exits with 0 for success, 1 for failure.

https://travis-ci.org/usingjsonschema/ujs-jsonvalidate-python.svg?branch=master

Command Line / Script Use

To run the validation (command line or script), use the validate command with a file name (path optional). For example, to check the file example.json against the schema example_schema.json, use,

validate example.json example_schema.json

Library Function Use

validate (dataFile, schemaFile, refFiles, jsdbFile, callback)

Arguments:
dataFile String File name of JSON data file (path optional)
schemaFile String File name of JSON Schema file (path optional)
refFiles String[] Array of file names for $ref files (path optional)
jsdbFile String File name for JSDB file (path optional)

Returns:
code, data, message

- code is the validation result
- data is the validated JSON content from dataFile
- message is text message associated with the code

For example,

from jsonvalidate import validate, VALID

dataFile = "example.json"
schemaFile = "example_schema.json"
refFiles = ["ref1_schema.json", "ref2_schema.json"]
jsdbFile = None

code, data, message = validate (dataFile, schemaFile, refFiles, jsdbFile)
if code == VALID:
    print ("Valid JSON content");
else:
    print ("Error: " + str (message))

Installation

The program can be installed using pip, with the command,

pip install ujs-jsonvalidate

License

MIT

Release files for ujs-jsonvalidate 0.1.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 ujs-jsonvalidate 0.1.0
File Size Uploaded
ujs-jsonvalidate-0.1.0.zip 10.7 kB Details

Release files / ujs-jsonvalidate-0.1.0.zip

Download URL ujs-jsonvalidate-0.1.0.zip
Size 10.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e033d6e95860bae7a3948e983b4f3b9a4a033f7496ad1e0d486805c302230b56
BLAKE2b-256 checksum
How to use checksums
f58078cf137edafa40ebc60879f48955219616563a9d46ac72c597da76196890
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file

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