Example #1
0
        private static string Format(JsonDto rootObject)
        {
            using (StringWriter stringWriter = new StringWriter())
            {
                foreach (Channel channel in rootObject.Query.Results.Channels)
                {
                    stringWriter.WriteLine("");

                    Location l = channel.Location;

                    stringWriter.WriteLine((new { l.City, l.Region, l.Country }));

                    foreach (Forecast forecast in channel.Item.Forecast)
                    {
                        stringWriter.WriteLine(
                            new { forecast.Date, forecast.Day, forecast.High, forecast.Low, forecast.Text });
                    }
                }

                return(stringWriter.ToString());
            }
        }
Example #2
0
 public static string ToJson(this JsonDto self)
 {
     return(JsonConvert.SerializeObject(self, Converter.Settings));
 }
Example #3
0
        public override string DeserializeAndFormat(string responseData)
        {
            JsonDto rootObject = JsonDto.FromJson(responseData);

            return(Format(rootObject));
        }