我试图实现一个从类中返回Data的简单WebAPI。正确接收所有数据,使用锯齿状的字符串数组。 这是代码:
public IHttpActionResult GetGetGeoData_Result()
{
var results = db.GetGeoData().ToList();
List<GeoJsonResult> jsonResult = new List<GeoJsonResult>();
results.ForEach(r => jsonResult.Add(new GeoJsonResult()
{
Type = "Feature",
Geometry = new GeoJsonGeometry()
{
Type = r.geo_type,
Coordinates = this.CalculateCoordinates(r.coordinates) // This result is empty => Jagged string array (string[][])
},
Properties = new GeoJsonProperties()
{
Name = "SomeName"
}
}));
return Ok(jsonResult);
}
这是输出:
{
"odata.metadata": "http://localhost:65372/odata/$metadata#GetGeoData_Result",
"value": [
{
"Type": "Feature",
"Geometry": {
"Type": "Polygon",
"Coordinates": [
{},
{},
{},
{},
{},
{}
]
},
"Properties": {
"Name": "SomeName"
}
}] }
我做错了什么?