From 7f1a06148511cacebab96ddea70c6987604da28d Mon Sep 17 00:00:00 2001 From: "gu.martinm@gmail.com" Date: Wed, 23 Apr 2014 09:31:24 +0200 Subject: [PATCH] Parsing openweathermap JSON data. --- .../openweathermap/jsonparser/jsonparser.sln | 20 ++++ .../jsonparser/jsonparser/Program.cs | 116 +++++++++++++++++++++ .../jsonparser/Properties/AssemblyInfo.cs | 22 ++++ .../jsonparser/jsonparser/currentweather/Clouds.cs | 10 ++ .../jsonparser/jsonparser/currentweather/Coord.cs | 11 ++ .../jsonparser/currentweather/CurrentWeather.cs | 22 ++++ .../jsonparser/jsonparser/currentweather/Main.cs | 14 +++ .../jsonparser/jsonparser/currentweather/Rain.cs | 20 ++++ .../jsonparser/jsonparser/currentweather/Sys.cs | 13 +++ .../jsonparser/currentweather/Weather.cs | 13 +++ .../jsonparser/jsonparser/currentweather/Wind.cs | 11 ++ .../jsonparser/jsonparser/forecastweather/City.cs | 14 +++ .../jsonparser/jsonparser/forecastweather/Coord.cs | 11 ++ .../jsonparser/forecastweather/ForecastWeather.cs | 15 +++ .../jsonparser/jsonparser/forecastweather/List.cs | 19 ++++ .../jsonparser/jsonparser/forecastweather/Temp.cs | 15 +++ .../jsonparser/forecastweather/Weather.cs | 13 +++ .../jsonparser/jsonparser/jsonparser.csproj | 63 +++++++++++ .../jsonparsernofunciona/jsonparser.sln | 20 ++++ .../jsonparsernofunciona/jsonparser/Program.cs | 41 ++++++++ .../jsonparser/Properties/AssemblyInfo.cs | 22 ++++ .../jsonparser/currentweather/Clouds.cs | 10 ++ .../jsonparser/currentweather/Coord.cs | 11 ++ .../jsonparser/currentweather/CurrentWeather.cs | 22 ++++ .../jsonparser/currentweather/Main.cs | 14 +++ .../jsonparser/currentweather/Rain.cs | 20 ++++ .../jsonparser/currentweather/Sys.cs | 13 +++ .../jsonparser/currentweather/Weather.cs | 13 +++ .../jsonparser/currentweather/Wind.cs | 11 ++ .../jsonparser/jsonparser.csproj | 49 +++++++++ 30 files changed, 668 insertions(+) create mode 100644 Allgemeines/openweathermap/jsonparser/jsonparser.sln create mode 100644 Allgemeines/openweathermap/jsonparser/jsonparser/Program.cs create mode 100644 Allgemeines/openweathermap/jsonparser/jsonparser/Properties/AssemblyInfo.cs create mode 100644 Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Clouds.cs create mode 100644 Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Coord.cs create mode 100644 Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/CurrentWeather.cs create mode 100644 Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Main.cs create mode 100644 Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Rain.cs create mode 100644 Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Sys.cs create mode 100644 Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Weather.cs create mode 100644 Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Wind.cs create mode 100644 Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/City.cs create mode 100644 Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/Coord.cs create mode 100644 Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/ForecastWeather.cs create mode 100644 Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/List.cs create mode 100644 Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/Temp.cs create mode 100644 Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/Weather.cs create mode 100644 Allgemeines/openweathermap/jsonparser/jsonparser/jsonparser.csproj create mode 100644 Allgemeines/openweathermap/jsonparsernofunciona/jsonparser.sln create mode 100644 Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/Program.cs create mode 100644 Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/Properties/AssemblyInfo.cs create mode 100644 Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/Clouds.cs create mode 100644 Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/Coord.cs create mode 100644 Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/CurrentWeather.cs create mode 100644 Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/Main.cs create mode 100644 Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/Rain.cs create mode 100644 Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/Sys.cs create mode 100644 Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/Weather.cs create mode 100644 Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/Wind.cs create mode 100644 Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/jsonparser.csproj diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser.sln b/Allgemeines/openweathermap/jsonparser/jsonparser.sln new file mode 100644 index 0000000..df0cb7b --- /dev/null +++ b/Allgemeines/openweathermap/jsonparser/jsonparser.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "jsonparser", "jsonparser\jsonparser.csproj", "{8F70E570-9D59-4E94-825C-62087D3BB1F6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8F70E570-9D59-4E94-825C-62087D3BB1F6}.Debug|x86.ActiveCfg = Debug|x86 + {8F70E570-9D59-4E94-825C-62087D3BB1F6}.Debug|x86.Build.0 = Debug|x86 + {8F70E570-9D59-4E94-825C-62087D3BB1F6}.Release|x86.ActiveCfg = Release|x86 + {8F70E570-9D59-4E94-825C-62087D3BB1F6}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(MonoDevelopProperties) = preSolution + StartupItem = jsonparser\jsonparser.csproj + EndGlobalSection +EndGlobal diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser/Program.cs b/Allgemeines/openweathermap/jsonparser/jsonparser/Program.cs new file mode 100644 index 0000000..89a7951 --- /dev/null +++ b/Allgemeines/openweathermap/jsonparser/jsonparser/Program.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using Newtonsoft.Json; +using jsonparser.currentweather; +using jsonparser.forecastweather; + +namespace jsonparser +{ + class MainClass + { + /// + /// The _json settings. + /// + private static readonly JsonSerializerSettings _jsonSettings = + new JsonSerializerSettings + { + Error = delegate(object sender, Newtonsoft.Json.Serialization.ErrorEventArgs args) + { + Console.WriteLine(args.ErrorContext.Error.Message); + args.ErrorContext.Handled = true; + } + }; + + /// + /// The entry point of the program, where the program control starts and ends. + /// + /// The command-line arguments. + public static void Main(string[] args) + { + // Searching by geographic coordinates: + // http://api.openweathermap.org/data/2.5/weather?lat=57&lon=-2.15&cnt=1 + string jsonCurrentWeatherData = + "{" + + "\"coord\":{\"lon\":-2.15,\"lat\":57}," + + "\"sys\":{\"message\":0.0076,\"country\":\"GB\",\"sunrise\":1398227897,\"sunset\":1398281723}," + + "\"weather\":[{\"id\":741,\"main\":\"Fog\",\"description\":\"fog\",\"icon\":\"50n\"}]," + + "\"base\":\"cmc stations\"," + + "\"main\":{\"temp\":281.15,\"pressure\":1013,\"humidity\":100,\"temp_min\":281.15,\"temp_max\":281.15}," + + "\"wind\":{\"speed\":3.6,\"deg\":130}," + + "\"rain\":{\"3h\":0.5}," + + "\"clouds\":{\"all\":90}," + + "\"dt\":1398223200," + + "\"id\":2636814," + + "\"name\":" + + "\"Stonehaven\"," + + "\"cod\":200}"; + + // Getting daily forecast weather data: Searching 15 days forecast by + // geographic coordinates at JSON format + // http://api.openweathermap.org/data/2.5/forecast/daily?lat=57&lon=-2.15&cnt=15&mode=json + // By default units metric (meters per second) + // http://api.openweathermap.org/data/2.5/forecast/daily?lat=57&lon=-2.15&cnt=15&mode=json&units=imperial + // Imperial: miles per hour + // imperial value is multiplied by ~2.1605 which is close to conversion from m/s to mph (~2.236) + // http://bugs.openweathermap.org/issues/111 + string jsonForeCastWeatherData = + "{" + + "\"cod\":\"200\"," + + "\"message\":0.0048," + + "\"city\":{\"id\":2641549,\"name\":\"Newtonhill\",\"coord\":{\"lon\":-2.15,\"lat\":57.033329},\"country\":\"GB\",\"population\":0}," + + "\"cnt\":15," + + "\"list\":[" + + "{\"dt\":1397304000,\"temp\":{\"day\":286.15,\"min\":284.62,\"max\":286.15,\"night\":284.62,\"eve\":285.7,\"morn\":286.15},\"pressure\":1016.67,\"humidity\":84,\"weather\":[{\"id\":500,\"main\":\"Rain\",\"description\":\"light rain\",\"icon\":\"10d\"}],\"speed\":7.68,\"deg\":252,\"clouds\":0,\"rain\":0.25}," + + "{\"dt\":1397390400,\"temp\":{\"day\":284.92,\"min\":282.3,\"max\":284.92,\"night\":282.3,\"eve\":283.79,\"morn\":284.24},\"pressure\":1021.62,\"humidity\":84,\"weather\":[{\"id\":804,\"main\":\"Clouds\",\"description\":\"overcast clouds\",\"icon\":\"04d\"}],\"speed\":7.91,\"deg\":259,\"clouds\":92}," + + "{\"dt\":1397476800,\"temp\":{\"day\":282.1,\"min\":280.32,\"max\":282.1,\"night\":280.32,\"eve\":281.51,\"morn\":281.65},\"pressure\":1033.84,\"humidity\":92,\"weather\":[{\"id\":801,\"main\":\"Clouds\",\"description\":\"few clouds\",\"icon\":\"02d\"}],\"speed\":8.37,\"deg\":324,\"clouds\":20}," + + "{\"dt\":1397563200,\"temp\":{\"day\":280.73,\"min\":280.11,\"max\":281.4,\"night\":281.4,\"eve\":280.75,\"morn\":280.11},\"pressure\":1039.27,\"humidity\":97,\"weather\":[{\"id\":801,\"main\":\"Clouds\",\"description\":\"few clouds\",\"icon\":\"02d\"}],\"speed\":7.31,\"deg\":184,\"clouds\":12}," + + "{\"dt\":1397649600,\"temp\":{\"day\":281.73,\"min\":281.03,\"max\":282.22,\"night\":281.69,\"eve\":282.22,\"morn\":281.03},\"pressure\":1036.05,\"humidity\":90,\"weather\":[{\"id\":803,\"main\":\"Clouds\",\"description\":\"broken clouds\",\"icon\":\"04d\"}],\"speed\":7.61,\"deg\":205,\"clouds\":68}," + + "{\"dt\":1397736000,\"temp\":{\"day\":282.9,\"min\":281.45,\"max\":283.21,\"night\":282.71,\"eve\":283.06,\"morn\":281.49},\"pressure\":1029.39,\"humidity\":83,\"weather\":[{\"id\":803,\"main\":\"Clouds\",\"description\":\"broken clouds\",\"icon\":\"04d\"}],\"speed\":6.17,\"deg\":268,\"clouds\":56}," + + "{\"dt\":1397822400,\"temp\":{\"day\":285.26,\"min\":281.55,\"max\":285.26,\"night\":282.48,\"eve\":285.09,\"morn\":281.55},\"pressure\":1025.83,\"humidity\":0,\"weather\":[{\"id\":800,\"main\":\"Clear\",\"description\":\"sky is clear\",\"icon\":\"01d\"}],\"speed\":5.31,\"deg\":221,\"clouds\":10}," + + "{\"dt\":1397908800,\"temp\":{\"day\":284.29,\"min\":281.5,\"max\":284.29,\"night\":282.53,\"eve\":283.58,\"morn\":281.5},\"pressure\":1024.55,\"humidity\":0,\"weather\":[{\"id\":500,\"main\":\"Rain\",\"description\":\"light rain\",\"icon\":\"10d\"}],\"speed\":5.51,\"deg\":192,\"clouds\":6}," + + "{\"dt\":1397995200,\"temp\":{\"day\":283.36,\"min\":281.62,\"max\":284.34,\"night\":284.04,\"eve\":284.34,\"morn\":281.62},\"pressure\":1019.58,\"humidity\":0,\"weather\":[{\"id\":500,\"main\":\"Rain\",\"description\":\"light rain\",\"icon\":\"10d\"}],\"speed\":7.66,\"deg\":149,\"clouds\":0,\"rain\":0.48}," + + "{\"dt\":1398081600,\"temp\":{\"day\":282.24,\"min\":280.51,\"max\":282.41,\"night\":280.51,\"eve\":282.41,\"morn\":280.9},\"pressure\":1027.35,\"humidity\":0,\"weather\":[{\"id\":500,\"main\":\"Rain\",\"description\":\"light rain\",\"icon\":\"10d\"}],\"speed\":8.17,\"deg\":221,\"clouds\":10,\"rain\":0.94}," + + "{\"dt\":1398168000,\"temp\":{\"day\":282.28,\"min\":279.76,\"max\":282.28,\"night\":280.69,\"eve\":281.13,\"morn\":279.76},\"pressure\":1038.31,\"humidity\":0,\"weather\":[{\"id\":800,\"main\":\"Clear\",\"description\":\"sky is clear\",\"icon\":\"01d\"}],\"speed\":6.33,\"deg\":172,\"clouds\":1}," + + "{\"dt\":1398254400,\"temp\":{\"day\":281.54,\"min\":280.52,\"max\":281.54,\"night\":281.44,\"eve\":281.23,\"morn\":280.52},\"pressure\":1022.4,\"humidity\":0,\"weather\":[{\"id\":500,\"main\":\"Rain\",\"description\":\"light rain\",\"icon\":\"10d\"}],\"speed\":7.84,\"deg\":140,\"clouds\":91,\"rain\":1.24}," + + "{\"dt\":1398340800,\"temp\":{\"day\":282.1,\"min\":280.66,\"max\":282.78,\"night\":280.97,\"eve\":282.78,\"morn\":280.66},\"pressure\":1013.39,\"humidity\":0,\"weather\":[{\"id\":500,\"main\":\"Rain\",\"description\":\"light rain\",\"icon\":\"10d\"}],\"speed\":9.43,\"deg\":164,\"clouds\":98,\"rain\":1.03}," + + "{\"dt\":1398427200,\"temp\":{\"day\":282.11,\"min\":280.72,\"max\":282.32,\"night\":282.32,\"eve\":280.99,\"morn\":280.72},\"pressure\":1018.65,\"humidity\":0,\"weather\":[{\"id\":502,\"main\":\"Rain\",\"description\":\"heavy intensity rain\",\"icon\":\"10d\"}],\"speed\":5.26,\"deg\":158,\"clouds\":83,\"rain\":14.4}," + + "{\"dt\":1398513600,\"temp\":{\"day\":282.75,\"min\":280.61,\"max\":282.75,\"night\":280.61,\"eve\":281.75,\"morn\":281.96},\"pressure\":1007.4,\"humidity\":0,\"weather\":[{\"id\":500,\"main\":\"Rain\",\"description\":\"light rain\",\"icon\":\"10d\"}],\"speed\":9.18,\"deg\":198,\"clouds\":35,\"rain\":0.55}" + + "]}"; + + CurrentWeather current = JsonConvert.DeserializeObject(jsonCurrentWeatherData, _jsonSettings); + + Console.WriteLine("lat: " + current.coord.lat); + Console.WriteLine("lon: " + current.coord.lon); + foreach (jsonparser.currentweather.Weather weather in current.weather) + { + Console.WriteLine("description: " + weather.description); + Console.WriteLine("main: " + weather.main); + Console.WriteLine("id: " + weather.id); + Console.WriteLine("icon: " + weather.icon); + } + Console.WriteLine("humidity: " + current.main.humidity); + Console.WriteLine("pressure: " + current.main.pressure); + Console.WriteLine("temp: " + current.main.temp); + Console.WriteLine("temp_min: " + current.main.temp_min); + Console.WriteLine("temp_max: " + current.main.temp_max); + Console.WriteLine("rain: " + current.rain.get3h()); + Console.WriteLine("clouds: " + current.clouds.all); + + + ForecastWeather forecast = JsonConvert.DeserializeObject(jsonForeCastWeatherData, _jsonSettings); + + Console.WriteLine("lat: " + forecast.city.coord.lat); + Console.WriteLine("lon: " + forecast.city.coord.lon); + Console.WriteLine("name: " + forecast.city.name); + + foreach (jsonparser.forecastweather.List list in forecast.list) + { + Console.WriteLine("temp day: " + list.temp.day); + Console.WriteLine("temp eve: " + list.temp.eve); + Console.WriteLine("temp max: " + list.temp.max); + Console.WriteLine("temp min: " + list.temp.min); + } + } + } +} diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser/Properties/AssemblyInfo.cs b/Allgemeines/openweathermap/jsonparser/jsonparser/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..1eaca17 --- /dev/null +++ b/Allgemeines/openweathermap/jsonparser/jsonparser/Properties/AssemblyInfo.cs @@ -0,0 +1,22 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. +[assembly: AssemblyTitle("jsonparser")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("gumartinm.name")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("gumartinm.name")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. +[assembly: AssemblyVersion("1.0.*")] +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] + diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Clouds.cs b/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Clouds.cs new file mode 100644 index 0000000..e24f278 --- /dev/null +++ b/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Clouds.cs @@ -0,0 +1,10 @@ +using System; + +namespace jsonparser.currentweather +{ + public class Clouds + { + public int all { get; set; } + } +} + diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Coord.cs b/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Coord.cs new file mode 100644 index 0000000..c053510 --- /dev/null +++ b/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Coord.cs @@ -0,0 +1,11 @@ +using System; + +namespace jsonparser.currentweather +{ + public class Coord + { + public double lon { get; set; } + public int lat { get; set; } + } +} + diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/CurrentWeather.cs b/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/CurrentWeather.cs new file mode 100644 index 0000000..4fec718 --- /dev/null +++ b/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/CurrentWeather.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; + +namespace jsonparser.currentweather +{ + public class CurrentWeather + { + public Coord coord { get; set; } + public Sys sys { get; set; } + public List weather { get; set; } + public string @base { get; set; } + public Main main { get; set; } + public Wind wind { get; set; } + public Rain rain { get; set; } + public Clouds clouds { get; set; } + public int dt { get; set; } + public int id { get; set; } + public string name { get; set; } + public int cod { get; set; } + } +} + diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Main.cs b/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Main.cs new file mode 100644 index 0000000..39a7dd9 --- /dev/null +++ b/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Main.cs @@ -0,0 +1,14 @@ +using System; + +namespace jsonparser.currentweather +{ + public class Main + { + public double temp { get; set; } + public int pressure { get; set; } + public int humidity { get; set; } + public double temp_min { get; set; } + public double temp_max { get; set; } + } +} + diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Rain.cs b/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Rain.cs new file mode 100644 index 0000000..edff969 --- /dev/null +++ b/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Rain.cs @@ -0,0 +1,20 @@ +using System; + +namespace jsonparser.currentweather +{ + public class Rain + { + private double threeHours; + + public void set3h(double three) + { + this.threeHours = three; + } + + public double get3h() + { + return this.threeHours; + } + } +} + diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Sys.cs b/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Sys.cs new file mode 100644 index 0000000..06cff86 --- /dev/null +++ b/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Sys.cs @@ -0,0 +1,13 @@ +using System; + +namespace jsonparser.currentweather +{ + public class Sys + { + public double message { get; set; } + public string country { get; set; } + public int sunrise { get; set; } + public int sunset { get; set; } + } +} + diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Weather.cs b/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Weather.cs new file mode 100644 index 0000000..77bfffd --- /dev/null +++ b/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Weather.cs @@ -0,0 +1,13 @@ +using System; + +namespace jsonparser.currentweather +{ + public class Weather + { + public int id { get; set; } + public string main { get; set; } + public string description { get; set; } + public string icon { get; set; } + } +} + diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Wind.cs b/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Wind.cs new file mode 100644 index 0000000..e4f1087 --- /dev/null +++ b/Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Wind.cs @@ -0,0 +1,11 @@ +using System; + +namespace jsonparser.currentweather +{ + public class Wind + { + public double speed { get; set; } + public int deg { get; set; } + } +} + diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/City.cs b/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/City.cs new file mode 100644 index 0000000..5d301c4 --- /dev/null +++ b/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/City.cs @@ -0,0 +1,14 @@ +using System; + +namespace jsonparser.forecastweather +{ + public class City + { + public int id { get; set; } + public string name { get; set; } + public Coord coord { get; set; } + public string country { get; set; } + public int population { get; set; } + } +} + diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/Coord.cs b/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/Coord.cs new file mode 100644 index 0000000..065cb6d --- /dev/null +++ b/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/Coord.cs @@ -0,0 +1,11 @@ +using System; + +namespace jsonparser.forecastweather +{ + public class Coord + { + public double lon { get; set; } + public double lat { get; set; } + } +} + diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/ForecastWeather.cs b/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/ForecastWeather.cs new file mode 100644 index 0000000..9d29ded --- /dev/null +++ b/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/ForecastWeather.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; + +namespace jsonparser.forecastweather +{ + public class ForecastWeather + { + public string cod { get; set; } + public double message { get; set; } + public City city { get; set; } + public int cnt { get; set; } + public List list { get; set; } + } +} + diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/List.cs b/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/List.cs new file mode 100644 index 0000000..2d3d487 --- /dev/null +++ b/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/List.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; + +namespace jsonparser.forecastweather +{ + public class List + { + public int dt { get; set; } + public Temp temp { get; set; } + public double pressure { get; set; } + public int humidity { get; set; } + public List weather { get; set; } + public double speed { get; set; } + public int deg { get; set; } + public int clouds { get; set; } + public double rain { get; set; } + } +} + diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/Temp.cs b/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/Temp.cs new file mode 100644 index 0000000..dce70c2 --- /dev/null +++ b/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/Temp.cs @@ -0,0 +1,15 @@ +using System; + +namespace jsonparser.forecastweather +{ + public class Temp + { + public double day { get; set; } + public double min { get; set; } + public double max { get; set; } + public double night { get; set; } + public double eve { get; set; } + public double morn { get; set; } + } +} + diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/Weather.cs b/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/Weather.cs new file mode 100644 index 0000000..8c60109 --- /dev/null +++ b/Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/Weather.cs @@ -0,0 +1,13 @@ +using System; + +namespace jsonparser.forecastweather +{ + public class Weather + { + public int id { get; set; } + public string main { get; set; } + public string description { get; set; } + public string icon { get; set; } + } +} + diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser/jsonparser.csproj b/Allgemeines/openweathermap/jsonparser/jsonparser/jsonparser.csproj new file mode 100644 index 0000000..bd9e900 --- /dev/null +++ b/Allgemeines/openweathermap/jsonparser/jsonparser/jsonparser.csproj @@ -0,0 +1,63 @@ + + + + Debug + x86 + 12.0.0 + 2.0 + {8F70E570-9D59-4E94-825C-62087D3BB1F6} + Exe + jsonparser + jsonparser + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + true + x86 + + + full + true + bin\Release + prompt + 4 + true + x86 + + + + + monodevelop + True + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser.sln b/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser.sln new file mode 100644 index 0000000..1d2e79e --- /dev/null +++ b/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "jsonparser", "jsonparser\jsonparser.csproj", "{D2D89F92-D070-4D60-A728-1BDF897438DD}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D2D89F92-D070-4D60-A728-1BDF897438DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D2D89F92-D070-4D60-A728-1BDF897438DD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D2D89F92-D070-4D60-A728-1BDF897438DD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D2D89F92-D070-4D60-A728-1BDF897438DD}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(MonoDevelopProperties) = preSolution + StartupItem = jsonparser\jsonparser.csproj + EndGlobalSection +EndGlobal diff --git a/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/Program.cs b/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/Program.cs new file mode 100644 index 0000000..da1ed58 --- /dev/null +++ b/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/Program.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using jsonparser.currentweather; + +namespace jsonparser +{ + class MainClass + { + /// + /// The _json settings. + /// + private static readonly JsonSerializerSettings _jsonSettings = + new JsonSerializerSettings + { + Error = delegate(object sender, Newtonsoft.Json.Serialization.ErrorEventArgs args) + { + Console.WriteLine(args.ErrorContext.Error.Message); + args.ErrorContext.Handled = true; + } + }; + + public static void Main(string[] args) + { + Console.WriteLine("LOL"); + string jsonCurrentWeatherData = @"{""coord"":{""lon"":-2.15,""lat"":57},""sys"":{""message"":0.0076,""country"":""GB"",""sunrise"":1398227897,""sunset"":1398281723},""weather"":[{""id"":741,""main"":""Fog"",""description"":""fog"",""icon"":""50n""}],""base"":""cmc stations"",""main"":{""temp"":281.15,""pressure"":1013,""humidity"":100,""temp_min"":281.15,""temp_max"":281.15},""wind"":{""speed"":3.6,""deg"":130},""rain"":{""3h"":0.5},""clouds"":{""all"":90},""dt"":1398223200,""id"":2636814,""name"":""Stonehaven"",""cod"":200}"; + + + CurrentWeather currentWeather = ReadResponse(jsonCurrentWeatherData); + + } + + + private static CurrentWeather ReadResponse(string json) + { + return JsonConvert.DeserializeObject(json, _jsonSettings); + } + + } +} diff --git a/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/Properties/AssemblyInfo.cs b/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..1eaca17 --- /dev/null +++ b/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/Properties/AssemblyInfo.cs @@ -0,0 +1,22 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. +[assembly: AssemblyTitle("jsonparser")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("gumartinm.name")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("gumartinm.name")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. +[assembly: AssemblyVersion("1.0.*")] +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] + diff --git a/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/Clouds.cs b/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/Clouds.cs new file mode 100644 index 0000000..e24f278 --- /dev/null +++ b/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/Clouds.cs @@ -0,0 +1,10 @@ +using System; + +namespace jsonparser.currentweather +{ + public class Clouds + { + public int all { get; set; } + } +} + diff --git a/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/Coord.cs b/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/Coord.cs new file mode 100644 index 0000000..c053510 --- /dev/null +++ b/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/Coord.cs @@ -0,0 +1,11 @@ +using System; + +namespace jsonparser.currentweather +{ + public class Coord + { + public double lon { get; set; } + public int lat { get; set; } + } +} + diff --git a/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/CurrentWeather.cs b/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/CurrentWeather.cs new file mode 100644 index 0000000..4fec718 --- /dev/null +++ b/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/CurrentWeather.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; + +namespace jsonparser.currentweather +{ + public class CurrentWeather + { + public Coord coord { get; set; } + public Sys sys { get; set; } + public List weather { get; set; } + public string @base { get; set; } + public Main main { get; set; } + public Wind wind { get; set; } + public Rain rain { get; set; } + public Clouds clouds { get; set; } + public int dt { get; set; } + public int id { get; set; } + public string name { get; set; } + public int cod { get; set; } + } +} + diff --git a/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/Main.cs b/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/Main.cs new file mode 100644 index 0000000..39a7dd9 --- /dev/null +++ b/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/Main.cs @@ -0,0 +1,14 @@ +using System; + +namespace jsonparser.currentweather +{ + public class Main + { + public double temp { get; set; } + public int pressure { get; set; } + public int humidity { get; set; } + public double temp_min { get; set; } + public double temp_max { get; set; } + } +} + diff --git a/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/Rain.cs b/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/Rain.cs new file mode 100644 index 0000000..edff969 --- /dev/null +++ b/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/Rain.cs @@ -0,0 +1,20 @@ +using System; + +namespace jsonparser.currentweather +{ + public class Rain + { + private double threeHours; + + public void set3h(double three) + { + this.threeHours = three; + } + + public double get3h() + { + return this.threeHours; + } + } +} + diff --git a/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/Sys.cs b/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/Sys.cs new file mode 100644 index 0000000..06cff86 --- /dev/null +++ b/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/Sys.cs @@ -0,0 +1,13 @@ +using System; + +namespace jsonparser.currentweather +{ + public class Sys + { + public double message { get; set; } + public string country { get; set; } + public int sunrise { get; set; } + public int sunset { get; set; } + } +} + diff --git a/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/Weather.cs b/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/Weather.cs new file mode 100644 index 0000000..77bfffd --- /dev/null +++ b/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/Weather.cs @@ -0,0 +1,13 @@ +using System; + +namespace jsonparser.currentweather +{ + public class Weather + { + public int id { get; set; } + public string main { get; set; } + public string description { get; set; } + public string icon { get; set; } + } +} + diff --git a/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/Wind.cs b/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/Wind.cs new file mode 100644 index 0000000..e4f1087 --- /dev/null +++ b/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/Wind.cs @@ -0,0 +1,11 @@ +using System; + +namespace jsonparser.currentweather +{ + public class Wind + { + public double speed { get; set; } + public int deg { get; set; } + } +} + diff --git a/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/jsonparser.csproj b/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/jsonparser.csproj new file mode 100644 index 0000000..4ccc0e5 --- /dev/null +++ b/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/jsonparser.csproj @@ -0,0 +1,49 @@ + + + + Debug + AnyCPU + 12.0.0 + 2.0 + {D2D89F92-D070-4D60-A728-1BDF897438DD} + Exe + jsonparser + jsonparser + 65001 + v4.5 + + + false + bin\Debug + 4 + true + + + false + bin\Release + 4 + + + + + monodevelop + False + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- 2.1.4