public void Serialize(JsonFormatter f, JsonSchemaValidationContext c, object o) { var array = o as IEnumerable; using (f.BeginList()) { int i = 0; foreach (var x in array) { using (c.Push(i++)) { Items.Validator.Serialize(f, c, x); } } } }
public void KeyValue() { var p = new Point { X = 1, Vector = new float[] { 1, 2, 3 } }; var f = new JsonFormatter(); f.BeginMap(); f.Key(nameof(p.Vector)); f.BeginList(); f.Value(p.Vector[0]); f.Value(p.Vector[1]); f.Value(p.Vector[2]); f.EndList(); f.EndMap(); var json = JsonParser.Parse(new Utf8String(f.GetStoreBytes())); Assert.AreEqual(1, json.GetObjectCount()); Assert.AreEqual(1, json["Vector"][0].GetInt32()); }
public static ActionDisposer BeginListDisposable(this JsonFormatter f) { f.BeginList(); return(new ActionDisposer(() => f.EndList())); }