我如何在这个Json中使用foreach,我尝试使用多个foreach但是我不能这样做,我只想检索坐标数据。
目前这是我检索数据的代码而且这段代码不起作用,我收到一个错误:(Newtonsoft.Json.Linq.JProperty'不包含'coordinates'的定义。)
select to_char(YourTimeStampField,'HH:MM:SS') from YourTable
select to_char(YourTimeStampField,'HH24:MM:SS') from YourTable
答案 0 :(得分:0)
看结构:
{ <---layer #1
"authenticationResultCode": "ValidCredentials",
"brandLogoUri": "http:\/\/dev.virtualearth.net\/Branding\/logo_powered_by.png",
"copyright": "Copyright ...",
"resourceSets": [ <-- layer #2
{ <-- layer #3
"estimatedTotal": 1,
"resources": [ <-- layer #4
{ <-- layer #5
"__type": "Location:http:\/\/schemas.microsoft.com\/search\/local\/ws\/rest\/v1",
"bbox": [
41.298164367675781,
-5.2461638450622559,
51.099018096923828,
9.6006984710693359
],
"name": "France",
"point": { <--layer #6
"type": "Point",
"coordinates": [
coordinates
是6层,你在yoru代码中有4层非嵌套。
答案 1 :(得分:0)
point
是一个对象,而不是一个数组。
"point": { // <- Notice the '{'
"type": "Point",
"coordinates": [
46.637279510498047,
2.3382623195648193
]
},
以下是您的阅读方式:
foreach (var set in deserializedValue.resourceSets)
{
foreach (var resource in set.resources)
{
foreach (var coord in resource.point.coordinates)
{
var message = new MessageDialog("Coord: " + coord);
await message.ShowAsync();
}
}
}
答案 2 :(得分:0)
感谢您的回答,现在我应该如何将coord转换为字符串?