I've below JSON which I want to convert into C# classes so that I can manipulate values in code once loaded. Below is JSON that I'm trying to parse:
{
"objects": {
"gujarat": {
"type": "GeometryCollection",
"geometries": [{
"arcs": [
[0, 1],
[2]
],
"type": "Polygon",
"properties": {
"dt_code": "491",
"year": "2011_c"
}
},
{
"arcs": [
[
[3]
],
[
[4]
],
[
[5]
],
[
[6]
],
[
[7, 8]
],
[
[9]
],
[
[10, 11, 12, 13, 14, 15, 16]
]
],
"type": "MultiPolygon",
"properties": {
"dt_code": "480",
"year": "2011_c"
}
}
]
}
}
}
The real challenge I'm having is with the "arcs" property. If you look at the values for arcs property, it has two dimensional value in first object whereas three dimensional in second object..
Below are some examples that I've tried so far but they don't work:
//This doesn't load value for second object
public class Geometry
{
public int [][] arcs { get; set; }
public string type { get; set; }
public Dictionary<string, string> properties { get; set; }
}
//This fails in deserialization
public class Geometry
{
public int [][][] arcs { get; set; }
public string type { get; set; }
public Dictionary<string, string> properties { get; set; }
}
//This doesn't return value of arcs when it's serialized again and instead returns blank arrays.
public class Geometry
{
public dynamic arcs { get; set; }
public string type { get; set; }
public Dictionary<string, string> properties { get; set; }
}
I want to load this JSON object, manipulate some values and then serialize again to send it to requester.