-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
37 lines (27 loc) · 1.59 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System.Text.Json;
using SystemJson;
const string data =
"{\"items\":[{\"title\":\"Москва, Центральный федеральный округ, Россия\",\"id\":\"here:cm:namedplace:20654514\"," +
"\"resultType\":\"locality\",\"localityType\":\"city\",\"address\":{\"label\":" +
"\"Москва, Центральный федеральный округ, Россия\",\"countryCode\":\"RUS\",\"countryName\":\"Россия\"," +
"\"state\":\"Центральный федеральный округ\",\"county\":\"Москва\",\"city\":\"Москва\",\"postalCode\":" +
"\"125009\"},\"position\":{\"lat\":55.75696,\"lng\":37.61502},\"mapView\":{\"west\":36.80166,\"south\":" +
"55.14286,\"east\":37.96761,\"north\":56.00985},\"scoring\":{\"queryScore\":1.0,\"fieldScore\":{\"city\":" +
"1.0}}}]}";
using var doc = JsonDocument.Parse(data);
var items = doc.RootElement.GetProperty("items").EnumerateArray();
var geoData = new GeoCoderModel();
var geoCoderModels = new List<GeoCoderModel>();
foreach (var item in items)
{
geoData.Address = item.GetProperty("title").ToString();
geoData.Lat = item.GetProperty("position").GetProperty("lat").GetDouble();
geoData.Lon = item.GetProperty("position").GetProperty("lng").GetDouble();
geoCoderModels.Add(geoData);
geoCoderModels.Add(geoData);
}
var result = geoCoderModels.Distinct();
var date = DateTime.Now;
var day = date.Day;
Console.WriteLine(day);
Console.WriteLine("stop");