-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathearthquakes.cs
178 lines (131 loc) · 4.39 KB
/
earthquakes.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
//
// using QuickType;
//
// var earthquakes = Earthquakes.FromJson(jsonString);
namespace QuickType
{
using System;
using System.Collections.Generic;
using System.Globalization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
public partial class Earthquakes
{
[JsonProperty("type")]
public string Type { get; set; }
[JsonProperty("metadata")]
public Metadata Metadata { get; set; }
[JsonProperty("features")]
public Feature[] Features { get; set; }
[JsonProperty("bbox")]
public double[] Bbox { get; set; }
}
public partial class Feature
{
[JsonProperty("type")]
public string Type { get; set; }
[JsonProperty("properties")]
public Properties Properties { get; set; }
[JsonProperty("geometry")]
public Geometry Geometry { get; set; }
[JsonProperty("id")]
public string Id { get; set; }
}
public partial class Geometry
{
[JsonProperty("type")]
public string Type { get; set; }
[JsonProperty("coordinates")]
public double[] Coordinates { get; set; }
}
public partial class Properties
{
[JsonProperty("mag")]
public double Mag { get; set; }
[JsonProperty("place")]
public string Place { get; set; }
[JsonProperty("time")]
public long Time { get; set; }
[JsonProperty("updated")]
public long Updated { get; set; }
[JsonProperty("tz")]
public long Tz { get; set; }
[JsonProperty("url")]
public string Url { get; set; }
[JsonProperty("detail")]
public string Detail { get; set; }
[JsonProperty("felt")]
public long? Felt { get; set; }
[JsonProperty("cdi")]
public long? Cdi { get; set; }
[JsonProperty("mmi")]
public double? Mmi { get; set; }
[JsonProperty("alert")]
public object Alert { get; set; }
[JsonProperty("status")]
public string Status { get; set; }
[JsonProperty("tsunami")]
public long Tsunami { get; set; }
[JsonProperty("sig")]
public long Sig { get; set; }
[JsonProperty("net")]
public string Net { get; set; }
[JsonProperty("code")]
public string Code { get; set; }
[JsonProperty("ids")]
public string Ids { get; set; }
[JsonProperty("sources")]
public string Sources { get; set; }
[JsonProperty("types")]
public string Types { get; set; }
[JsonProperty("nst")]
public long? Nst { get; set; }
[JsonProperty("dmin")]
public double? Dmin { get; set; }
[JsonProperty("rms")]
public double Rms { get; set; }
[JsonProperty("gap")]
public long? Gap { get; set; }
[JsonProperty("magType")]
public string MagType { get; set; }
[JsonProperty("type")]
public string Type { get; set; }
[JsonProperty("title")]
public string Title { get; set; }
}
public partial class Metadata
{
[JsonProperty("generated")]
public long Generated { get; set; }
[JsonProperty("url")]
public string Url { get; set; }
[JsonProperty("title")]
public string Title { get; set; }
[JsonProperty("status")]
public long Status { get; set; }
[JsonProperty("api")]
public string Api { get; set; }
[JsonProperty("count")]
public long Count { get; set; }
}
public partial class Earthquakes
{
public static Earthquakes FromJson(string json) => JsonConvert.DeserializeObject<Earthquakes>(json, QuickType.Converter.Settings);
}
public static class Serialize
{
public static string ToJson(this Earthquakes self) => JsonConvert.SerializeObject(self, QuickType.Converter.Settings);
}
internal static class Converter
{
public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
{
MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
DateParseHandling = DateParseHandling.None,
Converters = {
new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
},
};
}
}