Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //json
- var hero = new Hero();
- hero.Name = "Egid Beyond Meta";
- hero.BattleRank = 5000;
- var output = JsonConvert.SerializeObject(hero);
- var deserialized = (Newtonsoft.Json.Linq.JObject)JsonConvert.DeserializeObject(output);
- // schema
- string schema = @"{
- 'title' : 'Hero',
- 'type' : 'object',
- 'Name' : {'type' : 'integer'},
- 'BattleRank' : {'type' : 'integer'},
- required: [ 'Name', 'BattleRank']
- }";
- var jsonSchema = JSchema.Parse(schema);
- // returns ture
- Console.WriteLine("is valid " + deserialized.IsValid(jsonSchema));
- Console.ReadLine();
Add Comment
Please, Sign In to add comment