1
如何用JavaScriptSeiralizer解析這個JSON?如何用JavaScriptSeiralizer解析這個JSON
response: { count: 149, items: [{ id: 318869260, album_id: -7, owner_id: 1, sizes: [{ src: 'http://cs7003.vk.me/c540101/v540101001/8512/Lz9Om2nH7ws.jpg', width: 68, height: 75, type: 's' }, { src: 'http://cs7003.vk.me/c540101/v540101001/8513/eTw2eVnJGZY.jpg', width: 118, height: 130, type: 'm' }, { src: 'http://cs7003.vk.me/c540101/v540101001/8514/xOgTUSphy0g.jpg', width: 549, height: 604, type: 'x' }, { src: 'http://cs7003.vk.me/c540101/v540101001/8515/AqjVSivDR7U.jpg', width: 609, height: 670, type: 'y' }, { src: 'http://cs7003.vk.me/c540101/v540101001/8516/n-kCiDpG3Ck.jpg', width: 130, height: 143, type: 'o' }, { src: 'http://cs7003.vk.me/c540101/v540101001/8517/9CcHWimcZ5g.jpg', width: 200, height: 220, type: 'p' }, { src: 'http://cs7003.vk.me/c540101/v540101001/8518/zQSPjAWRk2Y.jpg', width: 320, height: 352, type: 'q' }, { src: 'http://cs7003.vk.me/c540101/v540101001/8519/9YzsZ1OF1Sc.jpg', width: 510, height: 561, type: 'r' }], text: '', date: 1388437503, likes: { user_likes: 0, count: 11553 } }] }
如何讓類解析?
1類
Class Users
{
public List<Photo> response { get; set; }
}
2類
class Photo
{
public long id { get; set; }
public long abum_id { get; set; }
public long owner_id { get; set; }
public string photo_75 { get; set; }
public string photo_130 { get; set; }
public string photo_604 { get; set; }
public string photo_807 { get; set; }
public string photo_1280 { get; set; }
public string photo_2560 { get; set; }
public long width { get; set; }
public long height { get; set; }
public string text { get; set; }
public long date { get; set; }
public long post_id { get; set; }
}
反序列化:
var idList = new JavaScriptSerializer().Deserialize<Users>(getResponseFriend);