Giter Site home page Giter Site logo

json-schema-validator's Introduction

JSON Schema Validator

Simple python 3 program to perform JSON schema validation using the jsonschema package

Prerequisites

Install jsonschema:

pip3 install jsonschema

Syntax

usage: validate_json.py [-h] [-3 | -4] schema_filename json_filename

Validate a JSON payload against a JSON schema

positional arguments:
  schema_filename  filename of JSON schema
  json_filename    filename of JSON payload

optional arguments:
  -h, --help       show this help message and exit
  -3, --draft3     use JSON draft-3 validator
  -4, --draft4     use JSON draft-4 validator

Sample usage

Validate file sample_json_good.json against schema sample_schema.json using default validator:

$ python3 validate_json.py sample_schema.json sample_json_good.json
JSON Schema validation successful.

Validate file sample_json_good.json against schema sample_schema.json using draft-3 validator:

$ python3 validate_json.py -3 sample_schema.json sample_json_good.json
JSON Schema validation successful.

Validate file sample_json_good.json against schema sample_schema.json using draft-4 validator:

$ python3 validate_json.py -4 sample_schema.json sample_json_good.json
JSON Schema validation successful.

Validate file sample_json_bad.json against schema sample_schema.json using default validator:

$ python3 validate_json.py sample_schema.json sample_json_bad.json
JSON validation error: 'Invalid' is not of type 'number'

json-schema-validator's People

Contributors

billdodd avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.