json parse so

CSharp · Console

/Program.cs

using System;
using Newtonsoft.Json;	
using System.Collections.Generic;
using System.Linq;

public class Program
{
	public static void Main()
	{
		var json = @"{
   'coord':{
      'lon':26.1,
      'lat':44.44
   },
   'weather':[
      {
         'id':804,
         'main':'Clouds',
         'description':'overcast clouds',
         'icon':'04n'
      }
   ],
   'base':'stations',
   'main':{
      'temp':287.64,
      'pressure':1012,
      'humidity':87,
      'temp_min':287.15,
      'temp_max':288.15
   },
   'visibility':8000,
   'wind':{
      'speed':2.6,
      'deg':50
   },
   'clouds':{
      'all':100
   },
   'dt':1573682313,
   'sys':{
      'type':1,
      'id':6911,
      'country':'RO',
      'sunrise':1573708189,
      'sunset':1573743018
   },
   'timezone':7200,
   'id':683506,
   'name':'Bucharest',
   'cod':200
}";

 Class1.WeatherMain vreme = JsonConvert.DeserializeObject <Class1.WeatherMain>(json);
 vreme.Dump();
	}
}

public class Class1
    {
        public class coord
        {
            public double lat { get; set; }
            public double lon { get; set; }
        }

        public class weatherinfo
        {
            public int id { get; set; }
		    public string main { get; set; }
		    public string description { get; set; }
		    public string icon { get; set; }
        }

        public class WeatherMain
        {
           public coord coord { get; set; }
           public List<weatherinfo> weather { get; set; }

            public void display()
            {
                Console.WriteLine("lon: {0}", this.coord.lon);
                Console.WriteLine("lat: {0}", this.coord.lat);
                Console.WriteLine("id: {0}", string.Join(Environment.NewLine,this.weather.Select(c=>$"Weather:{c.main},Description:{c.description}")));
            }
        }     
    }
;