Пример #1
0
 private void DisplayJSON()
 {
     this.jsonview.Nodes.Clear();
     if (this.jsonObject == null)
     {
         this.inputstream.Seek(0, SeekOrigin.Begin);
         this.jsonObject = JSONReader.Parse(this.inputstream);
     }
     if (this.jsonObject is JSONDictionary)
     {
         PopulateTreeView(this.jsonview.Nodes, this.jsonObject as JSONDictionary);
     }
     this.jsonview.ExpandAll();
 }
Пример #2
0
        public void ParseTest()
        {
            string jsonAsText = "[ true, \"Value2\", false, null ]";
            object o          = JSONReader.Parse(jsonAsText);

            Assert.IsTrue(o is ArrayList);
            ArrayList a = o as ArrayList;

            Assert.AreEqual(4, a.Count);
            Assert.AreEqual(false, a[2]);

            jsonAsText = "{ \"Name\" : true }";
            o          = JSONReader.Parse(jsonAsText);
            Assert.IsTrue(o is JSONDictionary);

            jsonAsText = "{ \"name\" : [ true, \"Value2\", false ], \"sub\" : { \"subname\" : 1234 } }";
            o          = JSONReader.Parse(jsonAsText);
            Assert.IsTrue(o is JSONDictionary);
            JSONDictionary j = o as JSONDictionary;

            a = j["name"] as ArrayList;
            Assert.IsNotNull(a);
        }