有这样的回应:
[{
"pic_50" : "http://avt.appsmail.ru/mail/rogozina.zoya/_avatar50",
"friends_count" : 41,
"pic_hires_filed" : "http://content.foto.mail.ru/mail/rogozina.zoya/_myphoto/h-43.jpg",
"nick" : "самвел",
"is_friend" : 0,
"is_online" : 1,
"has_pic" : 1,
"pic_190" : "http://avt.appsmail.ru/mail/rogozina.zoya/_avatar190",
"referer_id" : "",
"pic_32" : "http://avt.appsmail.ru/mail/rogozina.zoya/_avatar32",
"referer_type" : "",
"last_visit" : "1385039467",
"location" : {
"country" : {
"name" : "Россия",
"id" : "24"
},
"city" : {
"name" : "Тюмень",
"id" : "1553"
},
"region" : {
"name" : "Тюменская обл.",
"id" : "280"
}
},
"uid" : "11070260334392665635",
"app_installed" : 1,
"status_text" : "",
"pic_filed" : "http://content.foto.mail.ru/mail/rogozina.zoya/_myphoto/i-43.jpg",
"pic_22" : "http://avt.appsmail.ru/mail/rogozina.zoya/_avatar22",
"pic_id" : "43",
"age" : 49,
"last_name" : "Кочарян",
"pic_big" : "http://avt.appsmail.ru/mail/rogozina.zoya/_avatarbig",
"is_verified" : 1,
"vip" : 0,
"birthday" : "11.11.1964",
"link" : "http://my.mail.ru/mail/rogozina.zoya/",
"pic_128" : "http://avt.appsmail.ru/mail/rogozina.zoya/_avatar128",
"sex" : 0,
"pic_small" : "http://avt.appsmail.ru/mail/rogozina.zoya/_avatarsmall",
"pic" : "http://avt.appsmail.ru/mail/rogozina.zoya/_avatar",
"pic_180" : "http://avt.appsmail.ru/mail/rogozina.zoya/_avatar180",
"first_name" : "Самвел",
"pic_40" : "http://avt.appsmail.ru/mail/rogozina.zoya/_avatar40"
}
]
如何反序列化?
答案 0 :(得分:4)
使用Newtonsoft JSON.NET(可从NuGet获得):
var array = (JArray)JsonConvert.DeserializeObject(json);
var obj = (JObject)array[0];
var pic180 = obj["pic_180"];
答案 1 :(得分:1)
我投了其他答案(JSON.NET可能是大多数人的最佳选择),但我个人更喜欢
http://wiki.unity3d.com/index.php/SimpleJSON
作为解串器。它很简单,在一个文件中可以包含在您的项目中。如果您在格式中有一些非标准,您可以轻松调整它。
答案 2 :(得分:0)
将Newtonsoft.Json库的引用添加到您的项目并尝试此代码
ClassName obj = JsonConvert.DeserializeObject<ClassName>(serializedJson);