Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

jsonschema in python

import json
import jsonschema
from jsonschema import validate

# Describe what kind of json you expect.
studentSchema = {
    "type": "object",
    "properties": {
        "name": {"type": "string"},
        "rollnumber": {"type": "number"},
        "marks": {"type": "number"},
    },
}

def validateJson(jsonData):
    try:
        validate(instance=jsonData, schema=studentSchema)
    except jsonschema.exceptions.ValidationError as err:
        return False
    return True
Comment

install jsonschema python

pip install jsonschema
Comment

PREVIOUS NEXT
Code Example
Python :: how to add attribute to class python 
Python :: Sending POST request in Django 
Python :: Iterate through characters of a string in python 
Python :: pip install django celery results 
Python :: matplotlib vertical tick labels 
Python :: python array methods 
Python :: python string format 
Python :: python last item in list 
Python :: python formdata requests 
Python :: match statement 
Python :: python put console window on top 
Python :: create new column pandas lambda function assign apply 
Python :: Python NumPy copyto function example 
Python :: capitalize first letter of each word python 
Python :: add to python list 
Python :: how to give a role permissions discord py 
Python :: check if numpy array contains only duplicates 
Python :: pandas get group 
Python :: save turtle programming python 
Python :: How to develop a UDP echo server in python? 
Python :: how to take multiple line input in python 
Python :: how to stop a program after 1 second in python 
Python :: how to print a variable in python 
Python :: learn python the hard way 
Python :: Python Tkinter Message Widget 
Python :: ffill python 
Python :: python check if list contains value 
Python :: how to find unique values in list in python 
Python :: python minigame 
Python :: github python api 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =