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


C# JsonReader.Close方法代码示例

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


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

示例1: BooleanTest

        public void BooleanTest()
        {
            string json = "[ true, false ]";

            JsonReader reader = new JsonReader (json);
            reader.Read ();

            reader.Read ();
            Assert.IsTrue ((bool) reader.Value, "A1");
            reader.Read ();
            Assert.IsTrue (! ((bool) reader.Value), "A2");

            reader.Close ();
        }
开发者ID:kvantetore,项目名称:litjson,代码行数:14,代码来源:JsonReaderTest.cs

示例2: ImportManyJsonTextPiecesTest

        public void ImportManyJsonTextPiecesTest()
        {
            string json_arrays = @"
                [ true, true, false, false ]
                [ 10, 0, -10 ]
                [ ""war is over"", ""if you want it"" ]
                ";

            JsonReader reader;
            JsonData   arrays;

            reader = new JsonReader (json_arrays);
            arrays = JsonMapper.ToObject (reader);

            Assert.IsFalse (reader.EndOfInput, "A1");

            Assert.IsTrue (arrays.IsArray, "A2");
            Assert.AreEqual (4, arrays.Count, "A3");
            Assert.AreEqual (true, (bool) arrays[0], "A4");

            arrays = JsonMapper.ToObject (reader);

            Assert.IsFalse (reader.EndOfInput, "A5");

            Assert.IsTrue (arrays.IsArray, "A6");
            Assert.AreEqual (3, arrays.Count, "A7");
            Assert.AreEqual (10, (int) arrays[0], "A8");

            arrays = JsonMapper.ToObject (reader);

            Assert.IsTrue (arrays.IsArray, "A9");
            Assert.AreEqual (2, arrays.Count, "A10");
            Assert.AreEqual ("war is over", (string) arrays[0], "A11");

            reader.Close ();

            string json_objects = @"
                {
                  ""title""  : ""First"",
                  ""name""   : ""First Window"",
                  ""width""  : 640,
                  ""height"" : 480
                }

                {
                  ""title""  : ""Second"",
                  ""name""   : ""Second Window"",
                  ""width""  : 800,
                  ""height"" : 600
                }
                ";

            reader = new JsonReader (json_objects);
            UiWindow window;

            window = JsonMapper.ToObject<UiWindow> (reader);

            Assert.IsFalse (reader.EndOfInput, "A12");

            Assert.AreEqual ("First", window.title, "A13");
            Assert.AreEqual (640, window.width, "A14");

            window = JsonMapper.ToObject<UiWindow> (reader);

            Assert.AreEqual ("Second", window.title, "A15");
            Assert.AreEqual (800, window.width, "A16");

            reader.Close ();

            // Read them in a loop to make sure we get the correct number of
            // iterations
            reader = new JsonReader (json_objects);

            int i = 0;

            while (! reader.EndOfInput) {
                window = JsonMapper.ToObject<UiWindow> (reader);
                i++;
            }

            Assert.AreEqual (2, i, "A17");
        }
开发者ID:kvantetore,项目名称:litjson,代码行数:82,代码来源:JsonMapperTest.cs

示例3: DoubleTest

        public void DoubleTest()
        {
            string json = @"[ 0.0, -0.0, 3.1416, 8e-3, 7E-5, -128.000009,
                   144e+3, 0.1e2 ]";

            JsonReader reader = new JsonReader (json);
            reader.Read ();

            reader.Read ();
            Assert.AreEqual ((double) reader.Value, 0.0,
                             Double.Epsilon, "A1");
            reader.Read ();
            Assert.AreEqual ((double) reader.Value, 0.0,
                             Double.Epsilon, "A2");
            reader.Read ();
            Assert.AreEqual ((double) reader.Value, 3.1416,
                             Double.Epsilon, "A3");
            reader.Read ();
            Assert.AreEqual ((double) reader.Value, 0.008,
                             Double.Epsilon, "A4");
            reader.Read ();
            Assert.AreEqual ((double) reader.Value, 0.00007,
                             Double.Epsilon, "A5");
            reader.Read ();
            Assert.AreEqual ((double) reader.Value, -128.000009,
                             Double.Epsilon, "A6");
            reader.Read ();
            Assert.AreEqual ((double) reader.Value, 144000.0,
                             Double.Epsilon, "A7");
            reader.Read ();
            Assert.AreEqual ((double) reader.Value, 10.0,
                             Double.Epsilon, "A8");

            reader.Close ();
        }
开发者ID:kvantetore,项目名称:litjson,代码行数:35,代码来源:JsonReaderTest.cs

示例4: StringsTest

        public void StringsTest()
        {
            string json =
                "[ \"abc 123 \\n\\f\\b\\t\\r \\\" \\\\ \\u263a \\u25CF\" ]";

            string str = "abc 123 \n\f\b\t\r \" \\ \u263a \u25cf";

            JsonReader reader = new JsonReader (json);
            reader.Read ();
            reader.Read ();

            Assert.AreEqual (str, reader.Value, "A1");

            reader.Close ();

            json = " [ '\"Hello\" \\'world\\'' ] ";
            str  = "\"Hello\" 'world'";

            reader = new JsonReader (json);
            reader.Read ();
            reader.Read ();

            Assert.AreEqual (str, reader.Value, "A2");

            reader.Close ();
        }
开发者ID:kvantetore,项目名称:litjson,代码行数:26,代码来源:JsonReaderTest.cs

示例5: NullTest

        public void NullTest()
        {
            string json = "[ null ]";

            JsonReader reader = new JsonReader (json);
            reader.Read ();

            reader.Read ();
            Assert.IsNull (reader.Value);

            reader.Close ();
        }
开发者ID:kvantetore,项目名称:litjson,代码行数:12,代码来源:JsonReaderTest.cs

示例6: LongTest

        public void LongTest()
        {
            string json = "[ 2147483648, -10000000000 ]";

            JsonReader reader = new JsonReader (json);
            reader.Read ();

            reader.Read ();
            Assert.AreEqual (typeof (Int64), reader.Value.GetType (), "A1");
            Assert.AreEqual (2147483648l, (long) reader.Value, "A2");
            reader.Read ();
            Assert.AreEqual (-10000000000l, (long) reader.Value, "A3");

            reader.Close ();
        }
开发者ID:kvantetore,项目名称:litjson,代码行数:15,代码来源:JsonReaderTest.cs

示例7: IntTest

        public void IntTest()
        {
            string json = "[ 0, -0, 123, 14400, -500 ]";

            JsonReader reader = new JsonReader (json);
            reader.Read ();

            reader.Read ();
            Assert.AreEqual ((int) reader.Value, 0, "A1");
            reader.Read ();
            Assert.AreEqual ((int) reader.Value, 0, "A2");
            reader.Read ();
            Assert.AreEqual ((int) reader.Value, 123, "A3");
            reader.Read ();
            Assert.AreEqual ((int) reader.Value, 14400, "A4");
            reader.Read ();
            Assert.AreEqual ((int) reader.Value, -500, "A5");

            reader.Close ();
        }
开发者ID:kvantetore,项目名称:litjson,代码行数:20,代码来源:JsonReaderTest.cs

示例8: EmptyStringTest

        public void EmptyStringTest()
        {
            string json = "[ \"\" ]";

            JsonReader reader = new JsonReader (json);
            reader.Read ();

            reader.Read ();
            Assert.AreEqual (reader.Value, String.Empty);

            reader.Close ();
        }
开发者ID:kvantetore,项目名称:litjson,代码行数:12,代码来源:JsonReaderTest.cs


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