Seggregation of Json Schema Validation and Json Validation

254 views Asked by At

I have a use case where I will take a json-schema as input, validate it, then keep in my system. Later I will get json data which I need to validate with above mentioned json-schema. given the scenario, I need to do two level of validations:

1. provided json-schema is valid or not.
2. Json is valid or not.

I am using json-schema-validator jar and could find only second level of validation, couldn't find json-schema validation in documentation. for example: lets say we have below sample json-schema:

{
"title": "Person",
"type": "object",
"properties": {
    "firstName": {
        "type": "string"
    },
    "lastName": {
        "type": "string"
    },
    "age": {
        "description": "Age in years",
        "type": "integer",
        "minimum": 0
    }
},
"required": ["firstName", "lastName"]
}

so how to validate this json-schema itself is valid or not?

2

There are 2 answers

0
erosb On BEST ANSWER

There is a working example here with the everit-org/json-schema implementation (just in case you want to use a maintained library): How to validate a json schema against the version spec it specifies in Java

0
esp On

You have to validate schema against meta-schema: http://json-schema.org/draft-04/schema