Validating json file with json schema file

47 views
Skip to first unread message

Newbee

unread,
Apr 17, 2019, 6:52:15 PM4/17/19
to jsonschema - An implementation of JSON Schema for Python
My scenario is, I am doing a get request and then writing the json data in json file. Now I have a separate file for json schema for the data that I have received. 
I want to compare my data with schema. I am trying to use jsonschema as-


import jsonschema as jsonschema

from jsonschema import validate
jsonschema -i  response.json test.schema

When i run this python script it throws me an error-
 jsonschema -i  response.json test.schema
                          ^
SyntaxError: invalid syntax

Process finished with exit code 1


Anyone has seen this issue before ? Please suggest


Jakob Damgaard Møller

unread,
Aug 17, 2019, 3:28:26 PM8/17/19
to jsonschema - An implementation of JSON Schema for Python
Hello,
as i understand, the line: jsonschema -i sample.json sample.schema 
Is a console command, so you should do:

Save json to file and run the command above, or:

from jsonschema import validate
schema = load schema_file using python
validate(instance=YOUR_DATA, schema=schema)

And you should see the result...
Reply all
Reply to author
Forward
0 new messages