【发布时间】:2013-11-07 11:38:17
【问题描述】:
我正在为 windows phone 8 工作..
我需要从 url 检索 Json 数据,我需要在数组中显示..
我的网址有这样的jsondata..
{ id: 9
address: "abc"
city: " chennai"
contact1: ""
contact2: ""
country: " india"
description: ""
}
我想知道如何检索这些数据并将其存储在数组中?
这是我用来检索 Json 数据的语句。
private string REST_URL = "my url"; //i'm using my url here to extract the json data..
String servicePath = REST_URL + "/data/" + query;
Detail[] detail = JsonConvert.DeserializeObject<Detail[]>(servicePath);
return detail;
我的完整 Json 数据
[
{
"id": 01,
"address": "12asdf",
"city": " chennai",
"contact1": "",
"contact2": "",
"country": " india",
"description": "",
"name": " david",
"region": "",
"state": " 033",
"website": "",
"image": "",
"PrayerTime": {
"id": 01,
"PrayerTime1": "00:52",
"PrayerTime2": "21:04",
"PrayerTime3": "12:27",
"PrayerTime4": "05:35",
"PrayerTime5": "21:04",
"created_at": null,
"PrayerTime6": "04:01",
"updated_at": null,
"organization_id": 001
}
},.............
}
【问题讨论】:
-
您遇到了什么问题?您发布的 JSON 不是数组,而是单个对象。
-
我需要将它存储到一个数组中......所以我该怎么做......?或者帮助我从 url 检索 json 数据并显示它..
-
你能发布整个 JSON 吗?如果有问题的 JSON 正确,则仅使用
Detail而不是Detail[]。 -
我已经更新了完整的 Json 数据..
-
看来您的 JSON 可能是错误的。使用 json2csharp.com 从 JSON 创建类。
标签: c# arrays json windows-phone-8