· 5 years ago · Aug 31, 2020, 05:10 PM
1using System;
2using System.Collections.Generic;
3using System.Text.Json;
4using System.Text.Json.Serialization;
5using unirest_net.http;
6
7namespace WeatherApp
8{
9 class Program
10 {
11 static void Main(string[] args)
12 {
13 HttpResponse<string> response = Unirest.get("https://climacell-microweather-v1.p.rapidapi.com/weather/nowcast?fields=temp&unit_system=si&lat=51.500153&lon=-0.1262362")
14 .header("X-RapidAPI-Host", "climacell-microweather-v1.p.rapidapi.com")
15 .header("X-RapidAPI-Key", "super secret api key")
16 .asJson<string>();
17
18 Console.WriteLine(response.Body);
19
20 //weatherForecast = JsonSerializer.Deserialize<WeatherInfo>(response.Body.ToString());
21 }
22 }
23
24 public class WeatherInfo
25 {
26 public float lat { get; set; }
27
28 public float lon { get; set; }
29
30 public Dictionary<string, Temperature> DayTemp { get; set; }
31
32 public Dictionary<string, ObvTime> obTime { get; set; }
33 }
34
35 public class Temperature
36 {
37 public float value { get; set; }
38
39 public string units { get; set; }
40 }
41
42 public class ObvTime
43 {
44 public string value { get; set; }
45 }
46}
47