我正在使用NewsBlur API进行开发,它返回一个订阅源列表。响应的JSON类型为:
{
"authenticated": true,
"user": "sathyabhat",
"feeds": {},
"flat_folders": { },
result: "ok"
}
其中feeds:
的类型为
"feeds": {
"96705": {
"feed_address": "http://www.linuxhaxor.net/",
"updated": "8492 hours",
"favicon_text_color": null,
"subs": 35,
"feed_link": "http://www.linuxhaxor.net/",
"favicon_fetching": true,
"nt": 0,
"updated_seconds_ago": 30573336,
"num_subscribers": 35,
"feed_title": "LinuxHaxor.net",
"favicon_fade": null,
"exception_type": "feed",
"exception_code": 503,
"favicon_color": null,
"active": true,
"ng": 0,
"feed_opens": 0,
"id": 96705,
"ps": 0,
"has_exception": true
},
"768840": {
"feed_address": "http://feeds.feedburner.com/PathikShahDotCom",
"updated": "3 hours",
"favicon_text_color": "black",
"subs": 1,
"feed_link": "http://www.pathikshah.com/blog",
"favicon_fetching": false,
"nt": 0,
"updated_seconds_ago": 13043,
"num_subscribers": 1,
"feed_title": "Pathik Shah",
"favicon_fade": "769456",
"favicon_color": "b2d092",
"active": true,
"ng": 0,
"feed_opens": 0,
"id": 768840,
"ps": 0
},
"768842": {
"feed_address": "http://feeds.preshit.net/preshit/blog",
"updated": "3 hours",
"favicon_text_color": null,
"subs": 1,
"feed_link": "http://preshit.net",
"favicon_fetching": false,
"nt": 3,
"updated_seconds_ago": 13536,
"num_subscribers": 1,
"feed_title": "Preshit Deorukhkar",
"favicon_fade": null,
"favicon_color": null,
"active": true,
"ng": 0,
"feed_opens": 1,
"id": 768842,
"ps": 0
},
"768843": {
"feed_address": "http://quizwith.net/feed/",
"updated": "3 hours",
"favicon_text_color": "white",
"subs": 1,
"feed_link": "http://quizwith.net",
"favicon_fetching": false,
"nt": 0,
"updated_seconds_ago": 11617,
"num_subscribers": 1,
"feed_title": "quizwith.net",
"favicon_fade": "c22900",
"favicon_color": "fe6501",
"active": true,
"ng": 0,
"feed_opens": 0,
"id": 768843,
"ps": 0
}
[...等等...]
}
基本上,这是一个订阅对象列表。现在,我正在尝试使用 JSON.net 将其反序列化为C#对象,但我的类成员被填充为null值。
我的类是基于我收到的响应建模的:
public class FeedResponse
{
public string authenticated { get; set; }
public string user { get; set; }
public List<feed> feeds { get; set; }
public string flat_folders { get; set; }
public string result { get; set; }
}
public class feed
{
public string feed_address { get; set; }
public string updated { get; set; }
public string favicon_text_color { get; set; }
public int subs { get; set; }
public string feed_link { get; set; }
public bool favicon_fetching { get; set; }
public string nt { get; set; }
public string updated_seconds_ago { get; set; }
public int num_subscribers { get; set; }
public string feed_title { get; set; }
public string favicon_fade { get; set; }
public string exception_type { get; set; }
public string exception_code { get; set; }
public string favicon_color { get; set; }
public bool active { get; set; }
public string ng { get; set; }
public int feed_opens { get; set; }
public int id { get; set; }
public bool has_exception { get; set; }
}
这是尝试反序列化(使用RestSharp)的代码行: return Execute<FeedResponse>(request);
显然,在尝试解析反馈响应的JSON时出现了问题。
有什么指点,告诉我我做错了什么吗?