In GeoJSON the same attribute coordinates can be an array or array of arrays.
How can I define the same attribute name but different types for the same json object?
public class Geometry
{
public string type { get; set; }
[BsonElement("coordinates")]
public List<List<List<double>>> coordinates { get; set; }
[BsonElement("coordinates")]
public List<List<List<List<double>>>> coordinates { get; set; }
}
coordinates can be 4d or 3d, how can I handle this variability?
example:
{
"type": "Polygon",
"coordinates": [
[
[
[
51.263632,
60.962938
],
[
30.884274,
20.065517
],
[
68.832044,
14.362602
],
[
51.263632,
60.962938
]
]
]
]
}
or
{
"type": "MultiPolygon",
"coordinates": [
[
[
[
43.182162,
64.042209
],
[
14.721334,
22.358269
],
[
51.263632,
17.738761
],
[
43.182162,
64.042209
]
]
],
[
[
[
55.831419,
51.446822
],
[
65.66973,
20.065517
],
[
97.64424,
37.509124
],
[
55.831419,
51.446822
]
]
]
]
}
My action is
[HttpPost]
public IActionResult<Geometry> Create(Geometry layer)
{
_layerService.Create(layer);
return NoContent();
}