json schema properties code example

Example: json schema

JSchema schema = JSchema.Parse(@"{
  'type': 'array',
  'item': {'type':'string'}
}");
JsonTextReader reader = new JsonTextReader(new StringReader(@"[
  'Developer',
  'Administrator'
]"));

JSchemaValidatingReader validatingReader = new JSchemaValidatingReader(reader);
validatingReader.Schema = schema;

JsonSerializer serializer = new JsonSerializer();
List<string> roles = serializer.Deserialize<List<string>>(validatingReader);

Tags:

Misc Example