Beispiel #1
0
        public void ParserTest()
        {
            var keyint = new JsonLoader.Loader().LoadStringAsJson("{\"key\":12344}");
            // Assert.AreEqual(("int", "12344"), keyint);
            // Console.WriteLine(keyint);

            var keystring = new JsonLoader.Loader().LoadStringAsJson("{\"key\": \"value\"}");
            // Assert.AreEqual(("string", "value"), keyint);

            var keystringhasdoublequote = new JsonLoader.Loader().LoadStringAsJson("{\"key\": \"va\\\"lue\"}");
            // Assert.AreEqual(("string", "va\"lue"), keyint);

            var keybool = new JsonLoader.Loader().LoadStringAsJson("{\"key\": true}");
            // Assert.AreEqual(("bool", "true"), keyint);
        }
Beispiel #2
0
        public static void Main(string[] args)
        {
            var dict = new JsonLoader.Loader();
            var map1 = dict.LoadStringAsJson("{ \"title\": \"test\", \"items\": [ 9999, \"hello\", {\"list\": [ 123 ] } ] }");

            Console.WriteLine(
                $"{dict.Get("title")} : {dict.Get("title") == map1["title"]}, " +
                $"{dict.Get("items.0")} : {dict.Get("items.0") == map1["items"][0]}, " +
                $"{dict.Get("items.2/list.0")} : {dict.Get("items.2/list.0") == map1["items"][2]["list"][0]}"
                );

            var map2 = dict.LoadWithPath("/Users/x0y14/dev/csharp/JsonLoaderCS/JsonLoaderCS/test.json");

            Console.WriteLine(
                $"{dict.Get("title")} : {dict.Get("title") == map2["title"]}, " +
                $"{dict.Get("items.0")} : {dict.Get("items.0") == map2["items"][0]}, " +
                $"{dict.Get("items.2/list.0")} : {dict.Get("items.2/list.0") == map2["items"][2]["list"][0]}"
                );
        }