public static string Serialize <T>(this JsonSchema s, T o, JsonSchemaValidationContext c = null) { var f = new JsonFormatter(); s.Serialize(f, o, c); return(f.ToString()); }
public static string Serialize <T>(this JsonSchema s, T o) { var f = new JsonFormatter(); s.Serialize(f, o); return(f.ToString()); }
public void IndentTest() { var formatter = new JsonFormatter(2); formatter.BeginMap(); formatter.Key("a"); formatter.Value(1); formatter.EndMap(); var json = formatter.ToString(); Debug.Log(json); }
public string Serialize(Object o) { var c = new JsonSchemaValidationContext(o); var ex = Validator.Validate(c, o); if (ex != null) { throw ex; } var f = new JsonFormatter(); Validator.Serialize(f, c, o); return(f.ToString()); }
public void CreateFromClass() { var s = JsonSchema.FromType <Person>(); Assert.AreEqual("Person", s.Title); var v = s.Validator as JsonObjectValidator; Assert.AreEqual("Age in years", v.Properties["age"].Description); //Assert.AreEqual(0, s.Properties["age"].Minimum); Assert.AreEqual(new[] { "firstName", "lastName" }, v.Required); var f = new JsonFormatter(2); s.ToJson(f); Debug.Log(f.ToString()); }
public void CreateFromClass() { var s = JsonSchema.FromType <Person>(); Assert.AreEqual("Person", s.Title); var v = s.Validator as JsonObjectValidator; Assert.AreEqual("Age in years", v.Properties["age"].Description); Assert.AreEqual(new[] { "firstName", "lastName" }, v.Required); var f = new JsonFormatter(2); s.ToJson(f); var json = f.ToString(); var parsed = JsonParser.Parse(json); Assert.AreEqual(0, parsed["properties"]["age"]["minimum"].GetInt32()); }