![]() |
VOOZH | about |
|
PM> Install-Package Newtonsoft.Json.Schema
|
or |
Install via VS Package Management window.
|
ZIP file containing Json.NET Schema assemblies and source code: Json.NET Schema
JSchema schema = JSchema.Parse(@"{
'type': 'object',
'properties': {
'name': {'type':'string'},
'roles': {'type': 'array'}
}
}");
JObject user = JObject.Parse(@"{
'name': 'Arnie Admin',
'roles': ['Developer', 'Administrator']
}");
bool valid = user.IsValid(schema);
// true
JSchemaGenerator generator = new JSchemaGenerator();
JSchema schema = generator.Generate(typeof(Account));
// {
// "type": "object",
// "properties": {
// "email": { "type": "string", "format": "email" }
// },
// "required": [ "email" ]
// }
public class Account
{
[EmailAddress]
[JsonProperty("email", Required = Required.Always)]
public string Email { get; set; }
}
var schema = JSchema.Parse(@"{
'type': 'array',
'item': {'type':'string'}
}");
var reader = new JsonTextReader(new StringReader(@"[
'Developer',
'Administrator'
]"));
var validatingReader = new JSchemaValidatingReader(reader);
validatingReader.Schema = schema;
var serializer = new JsonSerializer();
var roles = serializer.Deserialize<List<string>>(validatingReader);
Json.NET Schema passes 100% of the official JSON Schema Test Suite and has backwards compatibility with older standards.
The online schema validator at jsonschemavalidator.net uses Json.NET Schema and has been tested with tens of thousands of user schemas.
Designed with performance in mind, Json.NET Schema's unique streaming validation enables fast, efficient validation over any JSON.
Json.NET Schema is over twice as fast as the .NET Framework's XmlSchema when validating equivalent data.
Perpetual, royalty-free licenses are available for commercial use.
| Edition | Price |
|---|---|
| AGPL 3.0 | Free with limitations (1000 validations per hour) |
| 1 Developer Indie * | $129 USD |
| 1 Developer Business | $199 USD |
| Site License | $1299 USD |
* Companies or incorporated entities with more than 10 employees must purchase a Business plan.