Click or drag to resize
Json.NET

Parse JSON Schema from JSON

 

This sample parses a JsonSchema from JSON

Caution note Caution

Obsolete. JSON Schema validation has been moved to its own package. See http://www.newtonsoft.com/jsonschema for more details.

Sample
Usage
string schemaJson = @"{
  'description': 'A person',
  'type': 'object',
  'properties': {
    'name': {'type':'string'},
    'hobbies': {
      'type': 'array',
      'items': {'type':'string'}
    }
  }
}";

JsonSchema schema = JsonSchema.Parse(schemaJson);

Console.WriteLine(schema.Type);
// Object

foreach (var property in schema.Properties)
{
    Console.WriteLine(property.Key + " - " + property.Value.Type);
}
// name - String
// hobbies - Array