import json from jsonschema import validate str_schema = ''' { "$schema": "http://json-schema.org/draft-04/schema#", "title": "Product set", "type": "array", "items": { "title": "Product", "type": "object", "properties": { "id": { "description": "The unique identifier for a product", "type": "number" }, "name": { "type": "string" } }, "required": ["id", "name"] } } ''' str_p1 = ''' [ { "id": 2, "name": "An ice sculpture" } ] ''' str_p2 = ''' [ { "id": 1, "name": "An ice" }, { "id": 2, "name": "An ice sculpture" } ] ''' str_p3 = ''' [ { "id": 2, "name2": "An ice sculpture" } ] ''' schema = json.loads(str_schema) p1 = json.loads(str_p1) validate(p1, schema) p2 = json.loads(str_p2) validate(p2, schema) p3 = json.loads(str_p3) validate(p3, schema)