【发布时间】:2011-11-30 11:20:32
【问题描述】:
我想使用 JSon.net 反序列化 flickr.com 照片集(请参阅 http://www.flickr.com/services/api/flickr.photosets.getPhotos.html ) 我得到的 JSON 的一个例子是
{
photoset: {
id: "72154517991528243",
primary: "6346929005",
owner: "9999999@N00",
ownername: "myname",
photo: [
{
id: "6340104934",
secret: "18ab51078a",
server: "6106",
farm: 7,
title: "Day #1/30 - homemade kanelbullar",
isprimary: "0"
}
.... lots of these photos...
],
page: 1,
per_page: 500,
perpage: 500,
pages: 1,
total: "18"
},
stat: "ok"
}
我使用的类是这些:
class FlickrSet
{
Photoset photoset {get;set;}
string stat{get;set;}
}
class Photoset
{
public string id { get; set; }
public string primary { get; set; }
public string owner { get; set; }
public string ownername { get; set; }
public List<Photo> photo { get; set; }
public int page { get; set; }
public int per_page { get; set; }
public int perpage { get; set; }
public int pages { get; set; }
public string total { get; set; }
}
class Photo
{
public string id { get; set; }
public string secret { get; set; }
public string server { get; set; }
public int farm { get; set; }
public string title { get; set; }
public string isprimary { get; set; }
}
当我使用它们反序列化时:
var s= JsonConvert.DeserializeObject<FlickrSet>(outPut );
s 的两个成员都为 null。
我尝试匹配字符串、整数和列表,但我可能犯了一些错误。 谢谢大家!
【问题讨论】: