当前位置: 首页>>代码示例>>C#>>正文


C# JsonObject.ParseDocument方法代码示例

本文整理汇总了C#中JsonObject.ParseDocument方法的典型用法代码示例。如果您正苦于以下问题:C# JsonObject.ParseDocument方法的具体用法?C# JsonObject.ParseDocument怎么用?C# JsonObject.ParseDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JsonObject的用法示例。


在下文中一共展示了JsonObject.ParseDocument方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ArrayAccessToNotArray

        public void ArrayAccessToNotArray()
        {
            JsonObject json = new JsonObject();
            json.ParseDocument(input2);

            int i = 0;
            JsonValue v = json["myArrays"];

            Assert.Catch (typeof(JsonValueException), delegate { i = v[1].intValue; } );
            Assert.Catch (typeof(JsonValueException), delegate { i = v.array[1].intValue; } );
        }
开发者ID:hiroki-o,项目名称:NativeJsonTest,代码行数:11,代码来源:ArrayTests.cs

示例2: GetIPAddr

    IEnumerator GetIPAddr()
    {
        string url = serverAddr + "/jsontest/ip.json";

        WWW www = new WWW(url);
        yield return www;

        JsonObject json = new JsonObject();
        json.ParseDocument(www.text);

        getIpAddrTestSuccess = json["ip"].isString;
    }
开发者ID:hiroki-o,项目名称:NativeJsonTest,代码行数:12,代码来源:WWWTests.cs

示例3: GetString

    public void GetString()
    {
        JsonObject json = new JsonObject();
        json.ParseDocument(testInput1.text);

        // test direct query
        Assert.That ( json.IsString ("name1") );
        Assert.That ( json.GetString ("name1").Equals(value1) );

        JsonValue jv = json.GetValue("name1");
        Assert.That ( jv.isString );
        Assert.That ( jv.stringValue.Equals(value1) );
    }
开发者ID:hiroki-o,项目名称:NativeJsonTest,代码行数:13,代码来源:JsonExample.cs

示例4: MemberOrderConsistencyParseVsCode

        public void MemberOrderConsistencyParseVsCode()
        {
            JsonObject json  = new JsonObject();
            JsonObject json2 = new JsonObject();

            json.ParseDocument(input1);

            json2["member3"] = true;
            json2["member2"] = 456.789;
            json2["member4"] = false;
            json2["member1"] = 123;
            json2["member5"] = "hello world again";

            Assert.AreEqual(json.ToPrettyString(), json2.ToPrettyString());
        }
开发者ID:hiroki-o,项目名称:NativeJsonTest,代码行数:15,代码来源:ConsistencyTests.cs

示例5: ArrayModifyDuringEnumeration

        public void ArrayModifyDuringEnumeration()
        {
            JsonObject json = new JsonObject();
            json.ParseDocument(input);

            int i = 0;
            JsonValue v = json["myArrays"];

            i = 0;
            foreach(JsonValue item in v) {
                Assert.That ( item.intValue == values[i++] );
                if(i == 5) {
                    // modification during enumeration should
                    // raise InvalidOperationException
                    v.array.PushBack(99999);
                }
            }
        }
开发者ID:hiroki-o,项目名称:NativeJsonTest,代码行数:18,代码来源:EnumeratorTests.cs

示例6: ArrayIndexAccess

        public void ArrayIndexAccess()
        {
            JsonObject json = new JsonObject();
            json.ParseDocument(input);

            int i = 0;
            JsonValue v = json["myArrays"];

            Assert.That ( v.array.Count == values.Length );

            for(i=0; i< values.Length; ++i) {
                Assert.That ( v[i].intValue == values[i] );
            }

            i = 0;
            foreach(JsonValue item in v) {
                Assert.That ( item.intValue == values[i++] );
            }
        }
开发者ID:hiroki-o,项目名称:NativeJsonTest,代码行数:19,代码来源:ArrayTests.cs

示例7: ArrayEnumeration

        public void ArrayEnumeration()
        {
            JsonObject json = new JsonObject();
            json.ParseDocument(input);

            int i = 0;
            JsonValue v = json["myArrays"];

            Assert.That ( v.array.Count == values.Length );

            i = 0;
            foreach(JsonValue item in v) {
                Assert.That ( item.intValue == values[i++] );
            }

            i = 0;
            foreach(JsonValue item in v.array) {
                Assert.That ( item.intValue == values[i++] );
            }
        }
开发者ID:hiroki-o,项目名称:NativeJsonTest,代码行数:20,代码来源:EnumeratorTests.cs

示例8: TestDeserialize

        public void TestDeserialize()
        {
            JsonObject json = new JsonObject();
            json.ParseDocument(input);

            TestClass t = json.Deserialize<TestClass>();

            Assert.AreEqual (54321,    t.MyProp, "MyProp");

            Assert.AreEqual (12345,    				t.value1, "value1");
            Assert.AreEqual (true,     				t.value2, "value2");
            Assert.AreEqual (-1234567812345678L,   	t.value3, "value3");
            Assert.AreEqual (1234567812345678UL,  	t.value4, "value4");
            Assert.AreEqual ("hello, deserializer!",t.value5, "value5");
            Assert.AreEqual (314748364,   			t.value6, "value6");
            Assert.AreEqual (32,    				t.value7, "value7");

            Assert.AreEqual (TestClass.Mode.Dowit,       t.enumMode1, "enumMode1");
            Assert.AreEqual (TestClass.Mode.Go,          t.enumMode2, "enumMode2");

            Assert.AreEqual (987654,    					t.object1.MyProp, "object1.MyProp");
            Assert.AreEqual (67890,     					t.object1.value1, "object1.value1");
            Assert.AreEqual (false,     					t.object1.value2, "object1.value2");
            Assert.AreEqual (-8765432123456,     			t.object1.value3, "object1.value3");
            Assert.AreEqual (8765432123456,     			t.object1.value4, "object1.value4");
            Assert.AreEqual ("this is object within object, yay!",  t.object1.value5, "object1.value5");

            Assert.AreEqual (null, t.object2, "object2");

            JsonValueArray a = json["array1"].array;

            Assert.AreEqual (a.Count, t.array1.Length, "array1.Count");

            int i = 0;
            foreach(JsonValue v in json["array1"]) {
                Assert.AreEqual (v.intValue, t.array1[i++], "array1["+i+"]");
            }
        }
开发者ID:hiroki-o,项目名称:NativeJsonTest,代码行数:38,代码来源:DeserializationTest.cs

示例9: IsNotOtherThanString

    public void IsNotOtherThanString()
    {
        JsonObject json = new JsonObject();
        json.ParseDocument(testInput1);

        // test direct query
        Assert.That ( !json.IsArray ("name1") );
        Assert.That ( !json.IsBool ("name1") );
        Assert.That ( !json.IsDouble ("name1") );
        Assert.That ( !json.IsInt ("name1") );
        Assert.That ( !json.IsNull ("name1") );
        Assert.That ( !json.IsNumber ("name1") );
        Assert.That ( !json.IsObject ("name1") );

        JsonValue jv = json.GetValue("name1");
        Assert.That ( !jv.isArray );
        Assert.That ( !jv.isBool );
        Assert.That ( !jv.isDouble );
        Assert.That ( !jv.isInt );
        Assert.That ( !jv.isNull );
        Assert.That ( !jv.isNumber );
        Assert.That ( !jv.isObject );
    }
开发者ID:hiroki-o,项目名称:NativeJsonTest,代码行数:23,代码来源:JsonExample.cs

示例10: ArrayIndexWrite

        public void ArrayIndexWrite()
        {
            JsonObject json = new JsonObject();
            json.ParseDocument(input);

            JsonValue v = json["myArrays"];

            v[4] = 33333;

            for(int i=0; i< values2.Length; ++i) {
                Assert.That ( v[i].intValue == values2[i] );
            }
        }
开发者ID:hiroki-o,项目名称:NativeJsonTest,代码行数:13,代码来源:ArrayTests.cs

示例11: Parse

 public void Parse()
 {
     JsonObject json = new JsonObject();
     json.ParseDocument(testInput1);
 }
开发者ID:hiroki-o,项目名称:NativeJsonTest,代码行数:5,代码来源:JsonExample.cs

示例12: ParseTwoObject

 public void ParseTwoObject()
 {
     JsonObject json = new JsonObject();
     json.ParseDocument(jsonData);
     json.ParseDocument("{}");
 }
开发者ID:hiroki-o,项目名称:NativeJsonTest,代码行数:6,代码来源:ParserTests.cs

示例13: ParseRandom

 public void ParseRandom()
 {
     JsonObject json = new JsonObject();
     json.ParseDocument(@"[
       null,
       [
         null
       ],
       [
         []
       ]
     ]");
 }
开发者ID:hiroki-o,项目名称:NativeJsonTest,代码行数:13,代码来源:ParserTests.cs

示例14: ParseObjectEmptyArray

 public void ParseObjectEmptyArray()
 {
     JsonObject json = new JsonObject();
     json.ParseDocument("{\"Assets\" : []}");
 }
开发者ID:hiroki-o,项目名称:NativeJsonTest,代码行数:5,代码来源:ParserTests.cs

示例15: ParseModifyAndToString

    public void ParseModifyAndToString()
    {
        JsonObject json = new JsonObject();
        json.ParseDocument(testInput1);

        json.AddMember("category", "INIT");
        json.AddMember("data_value","foobar");

        JsonValue v = json["name1"];

        json["name1"].SetString ("adsjlfajsdlfajsdflajs dsjfjdfajd.");
        json["name2"].SetDouble(345.678);

        Debug.Log (json.ToPrettyString ());
    }
开发者ID:hiroki-o,项目名称:NativeJsonTest,代码行数:15,代码来源:JsonExample.cs


注:本文中的JsonObject.ParseDocument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。