我使用Facebook的圖形API來搜索網頁,https://graph.facebook.com/search?q=platform&type=pageFacebook的圖形API反序列化的網頁搜索
這裏是JSON響應,我只包括一個:
{
"data": [
{
"category": "Media/news/publishing",
"category_list": [
{
"id": "108366235907857",
"name": "Newspaper"
}
],
"name": "Arab News",
"id": "10250877124"
}
],
"paging": {
"next": "https://graph.facebook.com/search?limit=1&offset=1&type=page&q=media&__after_id=10250877124"
}
}
現在,這裏是我的類在C#:
public class CategoryList
{
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
}
public class DataRoot
{
[JsonProperty("category")]
public string Category { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("category_list")]
public CategoryList[] CategoryList { get; set; }
}
public class Paging
{
[JsonProperty("next")]
public string Next { get; set; }
}
public class FacebookPageResults
{
[JsonProperty("data")]
public DataRoot[] Data { get; set; }
[JsonProperty("paging")]
public Paging Paging { get; set; }
}
這裏是奇怪的事情,當我嘗試反序列化 FacebookPageResults response = new JavaScriptSerializer().Deserialize<FacebookPageResults>(res);
,在所屬分類總是空,甚至沒有填滿。我曾嘗試使用List CategoryList {get;設置;}但結果是一樣的?
任何幫助或解決方法有關THI