Parsing openweathermap JSON data.
authorgu.martinm@gmail.com <gu.martinm@gmail.com>
Wed, 23 Apr 2014 07:31:24 +0000 (09:31 +0200)
committergu.martinm@gmail.com <gu.martinm@gmail.com>
Wed, 23 Apr 2014 07:31:24 +0000 (09:31 +0200)
30 files changed:
Allgemeines/openweathermap/jsonparser/jsonparser.sln [new file with mode: 0644]
Allgemeines/openweathermap/jsonparser/jsonparser/Program.cs [new file with mode: 0644]
Allgemeines/openweathermap/jsonparser/jsonparser/Properties/AssemblyInfo.cs [new file with mode: 0644]
Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Clouds.cs [new file with mode: 0644]
Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Coord.cs [new file with mode: 0644]
Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/CurrentWeather.cs [new file with mode: 0644]
Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Main.cs [new file with mode: 0644]
Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Rain.cs [new file with mode: 0644]
Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Sys.cs [new file with mode: 0644]
Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Weather.cs [new file with mode: 0644]
Allgemeines/openweathermap/jsonparser/jsonparser/currentweather/Wind.cs [new file with mode: 0644]
Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/City.cs [new file with mode: 0644]
Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/Coord.cs [new file with mode: 0644]
Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/ForecastWeather.cs [new file with mode: 0644]
Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/List.cs [new file with mode: 0644]
Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/Temp.cs [new file with mode: 0644]
Allgemeines/openweathermap/jsonparser/jsonparser/forecastweather/Weather.cs [new file with mode: 0644]
Allgemeines/openweathermap/jsonparser/jsonparser/jsonparser.csproj [new file with mode: 0644]
Allgemeines/openweathermap/jsonparsernofunciona/jsonparser.sln [new file with mode: 0644]
Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/Program.cs [new file with mode: 0644]
Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/Properties/AssemblyInfo.cs [new file with mode: 0644]
Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/Clouds.cs [new file with mode: 0644]
Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/Coord.cs [new file with mode: 0644]
Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/CurrentWeather.cs [new file with mode: 0644]
Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/Main.cs [new file with mode: 0644]
Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/Rain.cs [new file with mode: 0644]
Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/Sys.cs [new file with mode: 0644]
Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/Weather.cs [new file with mode: 0644]
Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/currentweather/Wind.cs [new file with mode: 0644]
Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/jsonparser.csproj [new file with mode: 0644]

diff --git a/Allgemeines/openweathermap/jsonparser/jsonparser.sln b/Allgemeines/openweathermap/jsonparser/jsonparser.sln
new file mode 100644 (file)
index 0000000..df0cb7b
--- /dev/null
@@ -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 (file)
index 0000000..89a7951
--- /dev/null
@@ -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
+    {
+        /// <summary>
+        /// The _json settings.
+        /// </summary>
+        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;
+                }
+            };
+
+        /// <summary>
+        /// The entry point of the program, where the program control starts and ends.
+        /// </summary>
+        /// <param name="args">The command-line arguments.</param>
+        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<CurrentWeather>(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<ForecastWeather>(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 (file)
index 0000000..1eaca17
--- /dev/null
@@ -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 (file)
index 0000000..e24f278
--- /dev/null
@@ -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 (file)
index 0000000..c053510
--- /dev/null
@@ -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 (file)
index 0000000..4fec718
--- /dev/null
@@ -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> 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 (file)
index 0000000..39a7dd9
--- /dev/null
@@ -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 (file)
index 0000000..edff969
--- /dev/null
@@ -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 (file)
index 0000000..06cff86
--- /dev/null
@@ -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 (file)
index 0000000..77bfffd
--- /dev/null
@@ -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 (file)
index 0000000..e4f1087
--- /dev/null
@@ -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 (file)
index 0000000..5d301c4
--- /dev/null
@@ -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 (file)
index 0000000..065cb6d
--- /dev/null
@@ -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 (file)
index 0000000..9d29ded
--- /dev/null
@@ -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<jsonparser.forecastweather.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 (file)
index 0000000..2d3d487
--- /dev/null
@@ -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> 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 (file)
index 0000000..dce70c2
--- /dev/null
@@ -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 (file)
index 0000000..8c60109
--- /dev/null
@@ -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 (file)
index 0000000..bd9e900
--- /dev/null
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+    <ProductVersion>12.0.0</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{8F70E570-9D59-4E94-825C-62087D3BB1F6}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <RootNamespace>jsonparser</RootNamespace>
+    <AssemblyName>jsonparser</AssemblyName>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug</OutputPath>
+    <DefineConstants>DEBUG;</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <Externalconsole>true</Externalconsole>
+    <PlatformTarget>x86</PlatformTarget>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+    <DebugType>full</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release</OutputPath>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <Externalconsole>true</Externalconsole>
+    <PlatformTarget>x86</PlatformTarget>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=c7439020c8fedf87">
+      <Package>monodevelop</Package>
+      <Private>True</Private>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Program.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="currentweather\Clouds.cs" />
+    <Compile Include="currentweather\Coord.cs" />
+    <Compile Include="currentweather\CurrentWeather.cs" />
+    <Compile Include="currentweather\Main.cs" />
+    <Compile Include="currentweather\Rain.cs" />
+    <Compile Include="currentweather\Sys.cs" />
+    <Compile Include="currentweather\Weather.cs" />
+    <Compile Include="currentweather\Wind.cs" />
+    <Compile Include="forecastweather\Coord.cs" />
+    <Compile Include="forecastweather\City.cs" />
+    <Compile Include="forecastweather\Temp.cs" />
+    <Compile Include="forecastweather\Weather.cs" />
+    <Compile Include="forecastweather\List.cs" />
+    <Compile Include="forecastweather\ForecastWeather.cs" />
+  </ItemGroup>
+  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+  <ItemGroup>
+    <Folder Include="currentweather\" />
+    <Folder Include="forecastweather\" />
+  </ItemGroup>
+</Project>
\ No newline at end of file
diff --git a/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser.sln b/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser.sln
new file mode 100644 (file)
index 0000000..1d2e79e
--- /dev/null
@@ -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 (file)
index 0000000..da1ed58
--- /dev/null
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using jsonparser.currentweather;
+
+namespace jsonparser
+{
+    class MainClass
+    {
+        /// <summary>
+        /// The _json settings.
+        /// </summary>
+        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<CurrentWeather>(json, _jsonSettings);
+        }
+
+    }
+}
diff --git a/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/Properties/AssemblyInfo.cs b/Allgemeines/openweathermap/jsonparsernofunciona/jsonparser/Properties/AssemblyInfo.cs
new file mode 100644 (file)
index 0000000..1eaca17
--- /dev/null
@@ -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 (file)
index 0000000..e24f278
--- /dev/null
@@ -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 (file)
index 0000000..c053510
--- /dev/null
@@ -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 (file)
index 0000000..4fec718
--- /dev/null
@@ -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> 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 (file)
index 0000000..39a7dd9
--- /dev/null
@@ -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 (file)
index 0000000..edff969
--- /dev/null
@@ -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 (file)
index 0000000..06cff86
--- /dev/null
@@ -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 (file)
index 0000000..77bfffd
--- /dev/null
@@ -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 (file)
index 0000000..e4f1087
--- /dev/null
@@ -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 (file)
index 0000000..4ccc0e5
--- /dev/null
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>12.0.0</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{D2D89F92-D070-4D60-A728-1BDF897438DD}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <RootNamespace>jsonparser</RootNamespace>
+    <AssemblyName>jsonparser</AssemblyName>
+    <CodePage>65001</CodePage>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug</OutputPath>
+    <WarningLevel>4</WarningLevel>
+    <Externalconsole>true</Externalconsole>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Release</OutputPath>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=c7439020c8fedf87">
+      <Package>monodevelop</Package>
+      <SpecificVersion>False</SpecificVersion>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Program.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="currentweather\Coord.cs" />
+    <Compile Include="currentweather\Sys.cs" />
+    <Compile Include="currentweather\Weather.cs" />
+    <Compile Include="currentweather\Main.cs" />
+    <Compile Include="currentweather\Wind.cs" />
+    <Compile Include="currentweather\Rain.cs" />
+    <Compile Include="currentweather\Clouds.cs" />
+    <Compile Include="currentweather\CurrentWeather.cs" />
+  </ItemGroup>
+  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+  <ItemGroup>
+    <Folder Include="currentweather\" />
+  </ItemGroup>
+</Project>
\ No newline at end of file