$json = ‘{"firstName":"ban", "lastName":"shan","age":1,"data":{"hobby":"coding"} }‘; $validator = new JsonSchema\Validator; $schema = file_get_contents("schema.json"); $validator->check(json_decode($json), json_decode($schema)); if ($validator->isValid()) { echo "The supplied JSON validates against the schema.\n"; } else { echo "JSON does not validate. Violations:\n"; foreach ($validator->getErrors() as $error) { echo sprintf("[%s] %s\n", $error[‘property‘], $error[‘message‘]); } }