-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSerializer.cs
186 lines (149 loc) · 4.33 KB
/
Serializer.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
179
180
181
182
183
184
185
186
// <auto-generated />
//
// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
//
// using QuickType;
//
// var welcome = Welcome.FromJson(jsonString);
// <auto-generated />
//
// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
//
// using QuickType;
//
// var welcome = Welcome.FromJson(jsonString);
namespace RoomsToTopoJson
{
using System;
using System.Collections.Generic;
using System.Globalization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.IO;
//public partial class Welcome
//{
// [JsonProperty("type")]
// public string Type { get; set; }
// [JsonProperty("transform")]
// public Transform Transform { get; set; }
// [JsonProperty("objects")]
// public Objects Objects { get; set; }
// [JsonProperty("arcs")]
// public List<List<List<long>>> Arcs { get; set; }
//}
//public partial class Objects
//{
// [JsonProperty("two-squares")]
// public TwoSquares TwoSquares { get; set; }
//}
//public partial class TwoSquares
//{
// [JsonProperty("type")]
// public string Type { get; set; }
// [JsonProperty("geometries")]
// public List<Geometry> Geometries { get; set; }
//}
//public partial class Geometry
//{
// [JsonProperty("type")]
// public string Type { get; set; }
// [JsonProperty("arcs")]
// public List<List<long>> Arcs { get; set; }
// [JsonProperty("properties")]
// public Properties Properties { get; set; }
//}
//public partial class Properties
//{
// [JsonProperty("name")]
// public string Name { get; set; }
//}
//public partial class Transform
//{
// [JsonProperty("scale")]
// public List<long> Scale { get; set; }
// [JsonProperty("translate")]
// public List<long> Translate { get; set; }
//}
//public partial class Welcome
//{
// public static Welcome FromJson(string json) => JsonConvert.DeserializeObject<Welcome>(json, RoomsToTopoJson.Converter.Settings);
//}
//public static class Serialize
//{
// public static string ToJson(this Welcome self) => JsonConvert.SerializeObject(self, RoomsToTopoJson.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 }
},
};
}
public class export
{
public static void serializeJason(Rootobject JsonInfo, string fileLocation)
{
string json = JsonConvert.SerializeObject(JsonInfo, RoomsToTopoJson.Converter.Settings);
using (StreamWriter file = File.CreateText(fileLocation))
{
JsonSerializer serializer = new JsonSerializer();
serializer.Serialize(file, JsonInfo);
}
}
}
}
//public class Rootobject
//{
// public string type { get; set; }
// public Transform transform { get; set; }
// public Objects objects { get; set; }
// public double[][][] arcs { get; set; }
//}
//public class Transform
//{
// public int[] scale { get; set; }
// public int[] translate { get; set; }
//}
//public class Objects
//{
// public TwoSquares twosquares { get; set; }
//}
//public class TwoSquares
//{
// public string type { get; set; }
// public Geometry[] geometries { get; set; }
//}
//public class Geometry
//{
// public string type { get; set; }
// public int[][] arcs { get; set; }
// public Properties properties { get; set; }
//}
//public class Properties
//{
// public string Department { get; set; }
//}
public class Rootobject
{
public string type { get; set; }
public Feature[] features { get; set; }
}
public class Feature
{
public string type { get; set; }
public Properties properties { get; set; }
public Geometry geometry { get; set; }
}
public class Properties
{
}
public class Geometry
{
public string type { get; set; }
public float[][][] coordinates { get; set; }
}