Exemplo n.º 1
0
        static void Main(string[] args)
        {
            String json = null;
            String jlt  = null;

            Parser.Default.ParseArguments <Options>(args).WithParsed <Options>(o => {
                if (o.JltPath != null)
                {
                    jlt = ReadFile(o.JltPath);
                }
                else if (o.JltString != null)
                {
                    jlt = o.JltString;
                    if (o.Verbose)
                    {
                        Console.WriteLine("jlt:");
                        Console.WriteLine(jlt);
                    }
                }
                if (o.JsonPath != null)
                {
                    json = ReadFile(o.JsonPath);
                }
                else if (o.JsonString != null)
                {
                    json = o.JsonString;
                    if (o.Verbose)
                    {
                        Console.WriteLine("json:");
                        Console.WriteLine(json);
                    }
                }
                JsonLTInterpreter interpreter = new JsonLTInterpreter();
                string result = interpreter.Run(json, jlt, o.AsString, o.Pretty);
                Console.WriteLine(result);
            });
        }
Exemplo n.º 2
0
        public void JsonAsJltTest()
        {
            string json     = "{}";
            string jsonLT   = ReadFile("JsonAsJltTest.jlt");
            string expected = "{\"description\":\"this jlt is just json\",\"someArray\":[\"str1\",\"str3\",\"str5\"],\"someObject\":{\"int\":123,\"bool\":true,\"string\":\"sdfsdfsdf\",\"null\":null}}";
            string result   = interpreter.Run(json, jsonLT);

            Assert.AreEqual(expected, result);
        }