Guest User

Untitled

a guest
Apr 21st, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. //json
  2. var hero = new Hero();
  3. hero.Name = "Egid Beyond Meta";
  4. hero.BattleRank = 5000;
  5.  
  6. var output = JsonConvert.SerializeObject(hero);
  7. var deserialized = (Newtonsoft.Json.Linq.JObject)JsonConvert.DeserializeObject(output);
  8.  
  9. // schema
  10. string schema = @"{
  11. 'title' : 'Hero',
  12. 'type' : 'object',
  13. 'Name' : {'type' : 'integer'},
  14. 'BattleRank' : {'type' : 'integer'},
  15. required: [ 'Name', 'BattleRank']
  16. }";
  17.  
  18. var jsonSchema = JSchema.Parse(schema);
  19.  
  20. // returns ture
  21. Console.WriteLine("is valid " + deserialized.IsValid(jsonSchema));
  22. Console.ReadLine();
Add Comment
Please, Sign In to add comment