How to validate JSON Schema according to Draft v4 using JSON.NET Schema or NJSONSchema?

I have been looking into both JSON.NET Schema and NJsonSchema. Both don't seem to have any property / method that identifies if a JSON Schema is a valid one and in accordance with draft v4.

Is it that only an exception will identify if a schema is valid, and even if it's valid, how will I check that it's draft v4 compatible?


You can use a JSON schema that describes JSON schema and use that to validate the JSON.

You can find a copy here - http://www.jsonschemavalidator.net/api/jsonschemastore/schema?schemaUrl=schema-draft-v4

string draftV4SchemaJson = @"{}"; // replace with content from http://www.jsonschemavalidator.net/api/jsonschemastore/schema?schemaUrl=schema-draft-v4

JSchema draftV4Schema = JSchema.Parse(draftV4SchemaJson);

JObject yourSchemaJson = JObject.Parse(@"{}"); // your schema

bool valid = yourSchemaJson.IsValid(draftV4Schema);