Exemple #1
0
 public void ToJson(JsonFormatter f)
 {
     f.BeginMap();
     if (!string.IsNullOrEmpty(Title))
     {
         f.Key("title"); f.Value(Title);
     }
     if (!string.IsNullOrEmpty(Description))
     {
         f.Key("description"); f.Value(Description);
     }
     Validator.ToJson(f);
     f.EndMap();
 }
 public void ToJson(JsonFormatter f)
 {
     f.Key("type"); f.Value("object");
     if (Properties.Count > 0)
     {
         f.Key("properties");
         f.BeginMap();
         foreach (var kv in Properties)
         {
             f.Key(kv.Key);
             kv.Value.ToJson(f);
         }
         f.EndMap();
     }
 }
        public void KeyValue()
        {
            var p = new Point
            {
                X      = 1,
                Vector = new float[] { 1, 2, 3 }
            };

            var f = new JsonFormatter();

            f.BeginMap();
            f.KeyValue(() => p.Vector);
            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 BeginMapDisposable(this JsonFormatter f)
 {
     f.BeginMap();
     return(new ActionDisposer(() => f.EndMap()));
 }