Exemple #1
0
        static void ListTest()
        {
            List <data> _data = new List <data>();

            _data.Add(new data()
            {
                Id      = 1,
                SSN     = 2,
                Message = "A Message"
            });

            Console.WriteLine(ChoJSONWriter.ToTextAll <data>(_data));
        }
Exemple #2
0
        static void Test1()
        {
            using (var r = ChoYamlReader <MyModel> .LoadText(yamlText1))
            {
                foreach (var rec in r)
                {
                    Console.WriteLine(rec.Dump());
                }
                return;

                Console.WriteLine(ChoJSONWriter <MyModel> .ToTextAll(r));
            }
        }
Exemple #3
0
        static void CombineJSONTest()
        {
            string json = @"[
  {
    ""deliveryDay"": ""2018-06-19T15:00:00.000+0300"",
    ""currencyCode"": ""TRY"",
    ""offerType"": ""HOURLY"",
    ""regionCode"": ""TR1"",
    ""offerDetails"": [
         {
           ""startPeriod"": ""1"",
            ""duration"": ""1"",
            ""offerPrices"": [
                {
                  ""price"": ""0"",
                   ""amount"": ""5""
                 }
               ]
             }
           ]
          },
  {
   ""deliveryDay"": ""2018-06-19T15:00:00.000+0300"",
   ""currencyCode"": ""TRY"",
   ""offerType"": ""HOURLY"",
   ""regionCode"": ""TR1"",
   ""offerDetails"": [
         {
           ""startPeriod"": ""1"",
           ""duration"": ""1"",
           ""offerPrices"": [
                {
                  ""price"": ""2000"",
                   ""amount"": ""5""
               }
              ]
            }
          ]
        }
       ]";


            StringBuilder sb = new StringBuilder();

            using (var p = ChoJSONReader.LoadText(json))
            {
                var list = p.GroupBy(r => r.deliveryDay).Select(r => new
                {
                    deliveryDay = r.Key,
                    r.First().currencyCode,
                    r.First().offerType,
                    r.First().regionCode,
                    offerDetails = new
                    {
                        ((Array)r.First().offerDetails).OfType <dynamic>().First().startPeriod,
                        ((Array)r.First().offerDetails).OfType <dynamic>().First().duration,
                        offerPrices = r.Select(r1 => ((Array)r1.offerDetails[0].offerPrices).OfType <object>().First()).ToArray()
                    }
                }).ToArray();

                Console.WriteLine(ChoJSONWriter.ToTextAll(list));
                //foreach (var rec in )
                //	Console.WriteLine(rec.Dump());
            }
        }