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


C# JsonObject.AddMember方法代码示例

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


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

示例1: BuildFromCode

    public void BuildFromCode()
    {
        JsonObject json = new JsonObject();

        json.AddMember("member1", "INIT");
        json.AddMember("member2","foobar");
        json.AddMember("member3");

        JsonValue jv = json.GetValue ("member3");
        jv.SetArray();
        jv.array.PushBack(1);
        jv.array.PushBack(2);
        jv.array.PushBack(3);
        jv.array.PushBack(4);

        JsonObject jsonObj = new JsonObject();
        jsonObj.AddMember("intv", 123);
        jsonObj.AddMember("srtv", "hoge");
        jsonObj.AddMember("doublev", 123.456);

        json.AddMember("member4", jsonObj);

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

示例2: CastToWringType

        public void CastToWringType()
        {
            JsonObject json = new JsonObject();

            json.AddMember("member1");

            json["member1"].stringValue = "hello world";

            Assert.Catch ( typeof(InvalidCastException), delegate { int v = (int)json["member1"]; } );
        }
开发者ID:hiroki-o,项目名称:NativeJsonTest,代码行数:10,代码来源:CastTests.cs

示例3: CastToString

        public void CastToString()
        {
            JsonObject json = new JsonObject();

            json.AddMember("member1");
            json["member1"].stringValue = "hello world";

            Assert.That ( "hello world" == (string)json["member1"] );
        }
开发者ID:hiroki-o,项目名称:NativeJsonTest,代码行数:9,代码来源:CastTests.cs

示例4: PropertiesOrderTest

        public void PropertiesOrderTest()
        {
            JsonObject data = new JsonObject ();

            string json = "{\"first\":\"one\",\"second\":\"two\"," +
                "\"third\":\"three\",\"fourth\":\"four\"}";

                data.AddMember("first", "one");
                data.AddMember("second", "two");
                data.AddMember("third", "three");
                data.AddMember("fourth", "four");
                Assert.AreEqual (json, data.ToString ());
        }
开发者ID:hiroki-o,项目名称:NativeJsonTest,代码行数:13,代码来源:JsonDataTest.cs

示例5: NullValue

        public void NullValue()
        {
            string json = "{\"test\":null}";

            JsonObject data = new JsonObject ();
            data.AddMember("test", (string)null);

            Assert.AreEqual (json, data.ToString ());
        }
开发者ID:hiroki-o,项目名称:NativeJsonTest,代码行数:9,代码来源:JsonDataTest.cs

示例6: GetKeysTest

        public void GetKeysTest()
        {
            JsonObject data = new JsonObject ();

            data.AddMember("first", "one");
            data.AddMember("second", "two");
            data.AddMember("third", "three");
            data.AddMember("fourth", "four");

            //Assert.AreEqual (4, data.Count, "A1");

            //foreach (string k in data.Keys)
            //    Assert.IsNotNull (data[k], "A2");
        }
开发者ID:hiroki-o,项目名称:NativeJsonTest,代码行数:14,代码来源:JsonDataTest.cs

示例7: EqualsTest

        public void EqualsTest()
        {
            JsonObject o = new JsonObject();
            o.AddMember("member");
            JsonValue a = o["member"];
            JsonValue b;

            // Compare ints
            a.intValue = 7;
            b = 7;
            Assert.IsTrue (a.Equals (b), "A1");

            Assert.IsFalse (a.Equals (null), "A2");

            b = 8;
            Assert.IsFalse (a.Equals (b), "A3");

            // Compare longs
            a.longValue = 10L;
            b = 10L;
            Assert.IsTrue (a.Equals (b), "A4");

            // Compare Long and Int (the same value)
            // NOTE:
            //  The expected behaviour of LitJson for (10.Equals(10L)) is False
            //  but Unity's Json will return True because that is more
            //  expected result in natural manner
            b = 10;
            Assert.AreEqual (10L.Equals(10), a.Equals (b), "A5");

            // Compare Long and Long (different value)
            b = 11L;
            Assert.IsFalse (a.Equals (b), "A6");

            // Compare doubles
            a.doubleValue = 78.9;
            b = 78.9;
            Assert.IsTrue (a.Equals (b), "A7");

            b = 78.899999;
            Assert.IsFalse (a.Equals (b), "A8");

            // Compare booleans
            a.boolValue = true;
            b = true;
            Assert.IsTrue (a.Equals (b), "A9");

            b.boolValue = false;
            Assert.IsFalse (a.Equals (b), "A10");

            // Compare strings
            a.stringValue = "walrus";
            b = "walrus";
            Assert.IsTrue (a.Equals (b), "A11");

            b = "Walrus";
            Assert.IsFalse (a.Equals (b), "A12");
        }
开发者ID:hiroki-o,项目名称:NativeJsonTest,代码行数:58,代码来源:JsonDataTest.cs

示例8: AsObjectTest

        public void AsObjectTest()
        {
            JsonObject data = new JsonObject ();

            data.AddMember("alignment", "left");
            //data["alignment"] = "left";
            data.AddMember("font", new JsonObject());
            data["font"].AddMember("name", "Arial");
            data["font"].AddMember("style", "italic");
            data["font"].AddMember("size", 10);
            data["font"].AddMember("color", "#fff");

            Assert.IsTrue (data.isObject, "A1");

            string json = @"{""alignment"":""left"",""font"":{""name"":""Arial"",""style"":""italic"",""size"":10,""color"":""#fff""}}";
            //Debug.Log (data.ToString ());

            Assert.AreEqual (json, data.ToString(), "A2");
        }
开发者ID:hiroki-o,项目名称:NativeJsonTest,代码行数:19,代码来源:JsonDataTest.cs

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