Newtonsoft.Json.Schema 4.0.2-beta1
Json.NET Schema
Json.NET Schema is a powerful, complete and easy to use JSON Schema framework for .NET
Validate JSON
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
Generate Schemas
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;
}
Validate Deserialization
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);
Links
Showing the top 20 packages that depend on Newtonsoft.Json.Schema.
Packages | Downloads |
---|---|
Microsoft.ApplicationInsights.Profiler.Core
Core Library for Microsoft Application Insights Profiler.
|
4 |
Microsoft.ApplicationInsights.Profiler.Core
Core Library for Microsoft Application Insights Profiler.
|
3 |
.NET Framework 3.5
- Newtonsoft.Json (>= 13.0.3)
.NET Framework 4.0
- Newtonsoft.Json (>= 13.0.3)
.NET Framework 4.5
- Newtonsoft.Json (>= 13.0.3)
.NET Standard 2.0
- Newtonsoft.Json (>= 13.0.3)
.NET Standard 2.1
- Newtonsoft.Json (>= 13.0.3)
Version | Downloads | Last updated |
---|---|---|
4.0.2-beta1 | 2 | 11/21/2024 |
4.0.1 | 2 | 11/21/2024 |
3.0.16 | 1 | 11/21/2024 |
3.0.15 | 2 | 10/22/2024 |
3.0.14 | 3 | 10/10/2022 |
3.0.13 | 1 | 11/21/2024 |
3.0.12 | 2 | 10/23/2024 |
3.0.11 | 3 | 10/06/2024 |
3.0.10 | 2 | 11/21/2024 |
3.0.9 | 1 | 11/21/2024 |
3.0.8 | 2 | 10/06/2024 |
3.0.7 | 2 | 10/22/2024 |
3.0.6 | 2 | 10/06/2024 |
3.0.5 | 1 | 11/21/2024 |
3.0.4 | 1 | 11/21/2024 |
3.0.3 | 2 | 10/20/2024 |
3.0.2 | 2 | 10/06/2024 |
3.0.1 | 2 | 10/21/2024 |
2.0.13 | 1 | 11/21/2024 |
2.0.12 | 2 | 11/06/2024 |
2.0.11 | 3 | 10/06/2024 |
2.0.10 | 2 | 10/24/2024 |
2.0.9 | 2 | 10/23/2024 |
2.0.8 | 3 | 10/06/2024 |
2.0.7 | 3 | 10/06/2024 |
2.0.6 | 1 | 11/21/2024 |
2.0.5 | 0 | 08/26/2016 |
2.0.4 | 3 | 10/06/2024 |
2.0.3 | 2 | 10/22/2024 |
2.0.2 | 3 | 10/06/2024 |
2.0.1 | 1 | 11/21/2024 |
1.0.11 | 1 | 11/21/2024 |
1.0.10 | 2 | 10/23/2024 |
1.0.9 | 1 | 11/21/2024 |
1.0.8 | 2 | 11/21/2024 |
1.0.7 | 3 | 10/06/2024 |
1.0.6 | 2 | 11/21/2024 |
1.0.5 | 1 | 11/21/2024 |
1.0.4 | 2 | 11/21/2024 |
1.0.3 | 2 | 10/06/2024 |
1.0.2 | 3 | 10/06/2024 |
1.0.1 | 3 | 10/06/2024 |