示例#1
0
文件: Program.cs 项目: xman086/ChoETL
        public static void JSON2XmlDateTimeTest()
        {
            string actual;
            string json = @"{
 ""start"": ""2019-10-24T10:37:27.590Z"",
 ""end"": ""2019-10-24T11:00:00.000Z"",
 ""requests/duration"": {
   ""avg"": 3819.55
 }
}";

            //using (var r = new ChoJSONReader(new StringBuilder(json))
            //    )
            //{
            //    Console.WriteLine(r.First().Dump());
            //}

            actual = ChoJSONWriter.ToText(ChoJSONReader.LoadText(json,
                                                                 new ChoJSONRecordConfiguration().Configure(c => c.JsonSerializerSettings = new Newtonsoft.Json.JsonSerializerSettings
            {
                DateParseHandling = Newtonsoft.Json.DateParseHandling.None
            })).FirstOrDefault()
                                          );

            Assert.AreEqual(json, actual);
        }
示例#2
0
文件: Program.cs 项目: xman086/ChoETL
        static void ByteArrayTest()
        {
            StringBuilder csv = new StringBuilder();

            using (var r = new ChoParquetReader(@"C:\Projects\GitHub\ChoETL\src\Test\ChoParquetWriterTest\bin\Debug\netcoreapp2.1\ByteArrayTest.parquet")
                           .ParquetOptions(o => o.TreatByteArrayAsString = true)
                   )
            {
                var dt = r.AsDataTable("x");
                Console.WriteLine(ChoJSONWriter.ToText(dt));
                return;

                using (var w = new ChoCSVWriter(csv)
                               .WithFirstLineHeader()
                               .UseNestedKeyFormat(false)
                       )
                    w.Write(r);
            }

            Console.WriteLine(csv.ToString());
        }
示例#3
0
        static void Sample50()
        {
            string json = @"
{
    ""home"": {
        ""0_15"": {
            ""goals"": 7,
            ""percentage"": 14
        },
        ""15_30"": {
            ""goals"": 6,
            ""percentage"": 12
        },
        ""30_45"": {
            ""goals"": 11,
            ""percentage"": 22
        },
        ""45_60"": {
            ""goals"": 4,
            ""percentage"": 8
        },
        ""60_75"": {
            ""goals"": 8,
            ""percentage"": 16
        },
        ""75_90"": {
            ""goals"": 14,
            ""percentage"": 28
        }
    },
    ""away"": {
        ""0_15"": {
            ""goals"": 7,
            ""percentage"": 15.56
        },
        ""15_30"": {
            ""goals"": 7,
            ""percentage"": 15.56
        },
        ""30_45"": {
            ""goals"": 5,
            ""percentage"": 11.11
        },
        ""45_60"": {
            ""goals"": 6,
            ""percentage"": 13.33
        },
        ""60_75"": {
            ""goals"": 13,
            ""percentage"": 28.89
        },
        ""75_90"": {
            ""goals"": 7,
            ""percentage"": 15.56
        }
    }
}";

            using (var p = ChoJSONReader <Rootobject> .LoadText(json).Configure(c => c.SupportMultipleContent = true))
            {
                //foreach (var rec in p)
                //	Console.WriteLine(rec.Dump());
                Console.WriteLine(ChoJSONWriter <Rootobject> .ToText(p.First(), new ChoJSONRecordConfiguration().Configure(c => c.SupportMultipleContent = true)));
            }
        }