Validate JSON against JSON Schema C#

I think that you just need to add ‘additionalProperties’: false to your schema. This will stop unknown properties being provided. So now your results will be:- True, False, False test code…. void Main() { var schema = JsonSchema.Parse( @”{ ‘type’: ‘object’, ‘properties’: { ‘name’: {‘type’:’string’}, ‘hobbies’: {‘type’: ‘array’} }, ‘additionalProperties’: false }”); IsValid(JObject.Parse( @”{ ‘name’: … Read more

How to use definitions in JSON schema (draft-04)

I think the recommended approach is the one shown in Json-Schema web, Example2. You need to use an enum to select schemas “by value”. In your case it would be something like: { “type”: “object”, “required”: [ “results” ], “properties”: { “results”: { “type”: “array”, “items”: { “oneOf”: [ { “$ref”: “#/definitions/person” }, { “$ref”: … Read more

Tool to generate JSON schema from JSON data [closed]

Summarising the other answers, here are the JSON schema generators proposed so far: Online: https://www.liquid-technologies.com/online-json-to-schema-converter (1 input) http://www.jsonschema.net (1 input) https://easy-json-schema.github.io (1 input) Python: https://github.com/gonvaled/jskemator (1 input but allows iteration) https://github.com/perenecabuto/json_schema_generator (1 input) https://github.com/rnd0101/json_schema_inferencer (1 input I think) https://pypi.python.org/pypi/genson/ (multiple inputs) https://pypi.python.org/pypi/skinfer (multiple inputs) NodeJS: https://github.com/Nijikokun/generate-schema (multiple inputs (pass object array)) https://github.com/easy-json-schema/easy-json-schema (1 input) https://github.com/aspecto-io/genson-js … Read more

jsonSchema attribute conditionally required

Depending on your situation, there are a few different approaches. I can think of four different ways to conditionally require a field. Dependencies The dependencies keyword is a conditional variation of the required keyword. Foreach property in dependencies, if the property is present in the JSON being validated, then the schema associated with that key … Read more