我必须从 json 中检索特定值。例如:字符串格式的“id”:“217331368373746”。下面是 json 查询和我访问 id=217331368373746 的代码
{
"id": "191746304265586",
"albums": {
"data": [
{
"id": "217331368373746",
"created_time": "2012-03-24T20:53:34+0000"
}
],
"paging": {
"next": "https://graph.facebook.com/191746304265586/albums?limit=1&fields=id&after=MjE3MzMxMzY4MzczNzQ2"
}
}
}
代码:
var jsonalbum = Retrivedata("https://graph.facebook.com/191746304265586?fields=albums.limit(1).fields(id)");
foreach (var objalbum in jsonalbum["albums"])
{
//here what code
}
public dynamic Retrivedata(string query)
{
var request = WebRequest.Create(query);
var twitpicResponse = (HttpWebResponse)request.GetResponse();
var reader = new StreamReader(twitpicResponse.GetResponseStream());
JavaScriptSerializer js = new JavaScriptSerializer();
return js.Deserialize<dynamic>(reader.ReadToEnd());
}