コード例 #1
0
ファイル: YahooWeatherQuery.cs プロジェクト: aodennison/2018
        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());
            }
        }
コード例 #2
0
 public static string ToJson(this JsonDto self)
 {
     return(JsonConvert.SerializeObject(self, Converter.Settings));
 }
コード例 #3
0
ファイル: YahooWeatherQuery.cs プロジェクト: aodennison/2018
        public override string DeserializeAndFormat(string responseData)
        {
            JsonDto rootObject = JsonDto.FromJson(responseData);

            return(Format(rootObject));
        }