- Регистрация
- 25.08.2014
- Сообщения
- 394
- Благодарностей
- 53
- Баллы
- 28
Подскажите, как десериализировать ответ такого плана:
Но видимо что-то не так делаю. Не работает оно. Задача в том, чтобы весь массив items загнать в таблицу.
Пробую такого рода код:{
"response":{
"count":678025,
"items":[
{
"id":93388,
"first_name":"Владислав",
"last_name":"Цыплухин",
"sex":2,
"nickname":"",
"domain":"vlad",
"screen_name":"vlad",
"bdate":"2.11.1987",
"city":{
"id":2,
"title":"Санкт-Петербург"
},
"country":{
"id":1,
"title":"Россия"
},
"photo_50":"https:\/\/pp.vk.me\/c309119\/v309119388\/10874\/FFy01QUk4TA.jpg",
"photo_100":"https:\/\/pp.vk.me\/c309119\/v309119388\/10873\/ZuyheR0kCLQ.jpg",
"photo_200_orig":"https:\/\/pp.vk.me\/c309119\/v309119388\/10870\/i20dqlbLVno.jpg",
"has_mobile":1,
"online":1,
"can_post":0,
"can_see_all_posts":1,
"can_write_private_message":1,
"home_phone":"",
"status":"Коммуна",
"last_seen":{
"time":1435499033,
"platform":7
},
"university":0,
"university_name":"",
"faculty":0,
"faculty_name":"",
"graduation":0,
"relation":1,
"universities":[
{
"id":318188,
"country":65,
"city":5266393,
"name":"Uni Siegen",
"faculty":2133458,
"faculty_name":"Fakultät III: Wirtschaftswissenschaften, Wirtschaftsinformatik und Wirtschaftsrecht",
"graduation":2007,
"education_form":"Дневное отделение"
},
{
"id":67,
"country":1,
"city":2,
"name":"СПбГЭУ (ФИНЭК)",
"faculty":2162001,
"faculty_name":"Экономики и финансов",
"chair":1854597,
"chair_name":"Экономики предприятия и производственного менеджмента",
"graduation":2012,
"education_form":"Дневное отделение",
"education_status":"Аспирант"
}
]
},
{
"id":3374683,
"first_name":"Людмила",
"last_name":"Angel",
"sex":1,
"nickname":"",
"domain":"sentenced_angel",
"screen_name":"sentenced_angel",
"bdate":"21.5",
"city":{
"id":1,
"title":"Москва"
},
"country":{
"id":1,
"title":"Россия"
},
"photo_50":"https:\/\/pp.vk.me\/c617424\/v617424683\/22074\/WOwQyDGNlkM.jpg",
"photo_100":"https:\/\/pp.vk.me\/c617424\/v617424683\/22073\/WhAZLz8-Xzs.jpg",
"photo_200_orig":"https:\/\/pp.vk.me\/c617424\/v617424683\/22070\/vxO_UNjlU2c.jpg",
"has_mobile":1,
"online":1,
"can_post":1,
"can_see_all_posts":1,
"can_write_private_message":1,
"status":"Let's go! ^^ 13.09 Witchcraft feat Draconian, клуб Volta",
"last_seen":{
"time":1435498592,
"platform":7
},
"university":219,
"university_name":"МАИ",
"faculty":867,
"faculty_name":"Иностранных языков\r\n",
"graduation":2007,
"education_form":"Дневное отделение",
"relation":6,
"universities":[
{
"id":219,
"country":1,
"city":1,
"name":"МАИ",
"faculty":867,
"faculty_name":"Иностранных языков\r\n",
"chair":8886,
"chair_name":"Лингвистики и переводоведения",
"graduation":2007,
"education_form":"Дневное отделение"
},
{
"id":507,
"country":1,
"city":57,
"name":"ЕаЛИ МГЛУ (бывш. ИГЛУ)",
"faculty":177612,
"faculty_name":"Лингвистики и образовательных технологий (бывш. Гуманитарно-педагогический, Европейских языков)",
"graduation":2003,
"education_form":"Дневное отделение"
}
]
},
{
"id":2536333,
"first_name":"Кирилл",
"last_name":"Демидов",
"sex":2,
"nickname":"",
"domain":"demidovkirill",
"screen_name":"demidovkirill",
"bdate":"18.11.1987",
"city":{
"id":123,
"title":"Самара"
},
"country":{
"id":1,
"title":"Россия"
},
"photo_50":"https:\/\/pp.vk.me\/c620225\/v620225333\/1c94\/BbUhmT64F6k.jpg",
"photo_100":"https:\/\/pp.vk.me\/c620225\/v620225333\/1c93\/B0rBAlOsW38.jpg",
"photo_200_orig":"https:\/\/pp.vk.me\/c620225\/v620225333\/1c91\/GqffowLOYew.jpg",
"has_mobile":1,
"online":0,
"can_post":0,
"can_see_all_posts":0,
"can_write_private_message":1,
"home_phone":"",
"status":"",
"last_seen":{
"time":1435496410,
"platform":2
}
},
{
"id":167022,
"first_name":"Артём",
"last_name":"Волков",
"sex":2,
"nickname":"Сергеевич",
"domain":"artem.volkov",
"screen_name":"artem.volkov",
"bdate":"2.10.1986",
"city":{
"id":1,
"title":"Москва"
},
"country":{
"id":1,
"title":"Россия"
},
"photo_50":"https:\/\/pp.vk.me\/c619824\/v619824022\/e836\/22-5lKjePm0.jpg",
"photo_100":"https:\/\/pp.vk.me\/c619824\/v619824022\/e835\/CezUCMP_y0w.jpg",
"photo_200_orig":"https:\/\/pp.vk.me\/c619824\/v619824022\/e832\/dX5I_PF9yfw.jpg",
"has_mobile":1,
"online":0,
"can_post":0,
"can_see_all_posts":0,
"can_write_private_message":0,
"status":"Не только актер, но и ведущий современного формата. Artemvolkov.com",
"last_seen":{
"time":1435479748,
"platform":2
},
"university":219,
"university_name":"МАИ",
"faculty":863,
"faculty_name":"Авиационной техники\r\n",
"graduation":2010,
"education_form":"Дневное отделение",
"education_status":"Студент (специалист)",
"relation":4,
"universities":[
{
"id":219,
"country":1,
"city":1,
"name":"МАИ",
"faculty":863,
"faculty_name":"Авиационной техники\r\n",
"chair":2532,
"chair_name":"Динамика и управление летательных аппаратов",
"graduation":2010,
"education_form":"Дневное отделение",
"education_status":"Студент (специалист)"
}
]
},
{
"id":1823520,
"first_name":"Юрий",
"last_name":"Дегтярев",
"sex":2,
"nickname":"",
"domain":"cheeseandrice",
"screen_name":"cheeseandrice",
"bdate":"29.11.1986",
"city":{
"id":1,
"title":"Москва"
},
"country":{
"id":1,
"title":"Россия"
},
"photo_50":"https:\/\/pp.vk.me\/c628522\/v628522520\/7f49\/s2K_4RDzsEQ.jpg",
"photo_100":"https:\/\/pp.vk.me\/c628522\/v628522520\/7f48\/9o4dSPTVbYU.jpg",
"photo_200_orig":"https:\/\/pp.vk.me\/c628522\/v628522520\/7f45\/uohNqEhD_M8.jpg",
"has_mobile":1,
"online":1,
"online_app":"3140623",
"online_mobile":1,
"can_post":0,
"can_see_all_posts":1,
"can_write_private_message":1,
"mobile_phone":"",
"home_phone":"",
"status":"Каждый получает такого Юру, какого заслуживает.",
"last_seen":{
"time":1435499300,
"platform":2
},
"university":343,
"university_name":"СГА",
"faculty":1536,
"faculty_name":"Менеджмента\r\n",
"graduation":2007,
"education_form":"Дневное отделение",
"education_status":"Выпускник (бакалавр)",
"relation":0,
"universities":[
{
"id":343,
"country":1,
"city":1,
"name":"СГА",
"faculty":1536,
"faculty_name":"Менеджмента\r\n",
"chair":17019,
"chair_name":"Менеджмента",
"graduation":2007,
"education_form":"Дневное отделение",
"education_status":"Выпускник (бакалавр)"
}
]
},
{
"id":26455814,
"first_name":"Антон",
"last_name":"Гольцов",
"sex":2,
"nickname":"★ A.G. Moscow Family ★",
"domain":"agrecords",
"screen_name":"agrecords",
"bdate":"12.1",
"city":{
"id":1,
"title":"Москва"
},
"country":{
"id":1,
"title":"Россия"
},
"photo_50":"https:\/\/cs7065.vk.me\/c7008\/v7008814\/12733\/0myeiNzCLKE.jpg",
"photo_100":"https:\/\/cs7065.vk.me\/c7008\/v7008814\/12732\/eKWutII7umY.jpg",
"photo_200_orig":"https:\/\/cs7065.vk.me\/c7008\/v7008814\/1272f\/bbNBWadaZcI.jpg",
"has_mobile":1,
"online":1,
"online_app":"3140623",
"online_mobile":1,
"can_post":1,
"can_see_all_posts":1,
"can_write_private_message":1,
"status":"УСЛУГИ ПИАРА! ПО ПОВОДУ СОТРУДНИЧЕСТВА ИЛИ РЕКЛАМЫ В ЛИЧКУ ПИШИТЕ!",
"last_seen":{
"time":1435499250,
"platform":2
},
"university":2,
"university_name":"МГУ",
"faculty":27,
"faculty_name":"Журналистики",
"graduation":2010,
"education_form":"Дневное отделение",
"education_status":"Выпускник (специалист)",
"relation":6,
"universities":[
{
"id":2,
"country":1,
"city":1,
"name":"МГУ",
"faculty":27,
"faculty_name":"Журналистики",
"chair":368,
"chair_name":"Телевидения и радиовещания\r\n",
"graduation":2010,
"education_form":"Дневное отделение",
"education_status":"Выпускник (специалист)"
},
{
"id":263,
"country":1,
"city":1,
"name":"МГУПС (МИИТ)",
"faculty":1125,
"faculty_name":"Институт экономики и финансов\r\n",
"chair":12496,
"chair_name":"Экономика строительного бизнеса и управление собственностью",
"graduation":2013,
"education_form":"Дневное отделение",
"education_status":"Выпускник (специалист)"
}
]
},
{
"id":1456214,
"first_name":"Жорик",
"last_name":"Ревазов",
"sex":2,
"nickname":"",
"domain":"id1456214",
"screen_name":"id1456214",
"bdate":"2.7.1984",
"city":{
"id":38,
"title":"Владикавказ"
},
"country":{
"id":1,
"title":"Россия"
},
"photo_50":"https:\/\/pp.vk.me\/c624526\/v624526214\/394b1\/SmgcQLE08ws.jpg",
"photo_100":"https:\/\/pp.vk.me\/c624526\/v624526214\/394b0\/ZTe-K-AeSko.jpg",
"photo_200_orig":"https:\/\/pp.vk.me\/c624526\/v624526214\/394ad\/Fue6XtvnsCQ.jpg",
"has_mobile":1,
"online":1,
"can_post":0,
"can_see_all_posts":1,
"can_write_private_message":0,
"status":"Подписывайтесь на страничку, каждый день интересные фото и видео которых нет на ютубе. ",
"last_seen":{
"time":1435498874,
"platform":7
},
"university":419,
"university_name":"СКГМИ (ГТУ)",
"faculty":0,
"faculty_name":"",
"graduation":0,
"education_form":"Дневное отделение",
"education_status":"Доктор наук",
"relation":1,
"universities":[
{
"id":419,
"country":1,
"city":38,
"name":"СКГМИ (ГТУ)",
"education_form":"Дневное отделение",
"education_status":"Доктор наук"
}
]
},
{
"id":109006286,
"first_name":"Илья",
"last_name":"Коробко",
"sex":2,
"nickname":"",
"domain":"korobko001",
"screen_name":"korobko001",
"bdate":"14.1.1992",
"city":{
"id":1,
"title":"Москва"
},
"country":{
"id":1,
"title":"Россия"
},
"photo_50":"https:\/\/pp.vk.me\/c424726\/v424726286\/7086\/0K0qdSBIBB4.jpg",
"photo_100":"https:\/\/pp.vk.me\/c424726\/v424726286\/7085\/uUUlrJb4E4w.jpg",
"photo_200_orig":"https:\/\/pp.vk.me\/c424726\/v424726286\/7083\/0LZhMIck64g.jpg",
"has_mobile":0,
"online":0,
"can_post":0,
"can_see_all_posts":0,
"can_write_private_message":0,
"mobile_phone":"8-9..-..5-55-..",
"status":"Доброе братство дороже богатства !",
"last_seen":{
"time":1387307096,
"platform":7
}
},
{
"id":193028632,
"first_name":"Денис",
"last_name":"Мороз",
"sex":2,
"nickname":"Денисион",
"domain":"id193028632",
"screen_name":"id193028632",
"bdate":"16.10.1995",
"city":{
"id":280,
"title":"Харьков"
},
"country":{
"id":2,
"title":"Украина"
},
"photo_50":"https:\/\/cs7065.vk.me\/c7003\/v7003136\/9528\/Mvr4HPfp_2k.jpg",
"photo_100":"https:\/\/cs7065.vk.me\/c7003\/v7003190\/9355\/Ne4pG-AePNs.jpg",
"photo_200_orig":"https:\/\/cs7065.vk.me\/c7003\/v7003900\/962b\/9cuadFJKmBY.jpg",
"has_mobile":1,
"online":1,
"can_post":0,
"can_see_all_posts":1,
"can_write_private_message":1,
"mobile_phone":" STEAM ДЕНИСИОН",
"status":"",
"last_seen":{
"time":1435498722,
"platform":7
}
}
]
}
}
Код:
var json = project.Variables["getSearchResult"].Value;
var jsoner = new System.Web.Script.Serialization.JavaScriptSerializer();
Dictionary<string,object> data = jsoner.Deserialize<Dictionary<string,object>>(json);
var response = (System.Collections.ArrayList)data["response"];
var table = project.Tables["Members"];
foreach (var item in response)
{
var membersCount = ((Dictionary<string,object>)(item))["count"].ToString();
var members = ((Dictionary<string,object>)(item))["items"].ToArray;
lock(SyncObjects.TableSyncer);
{
foreach (var member in members)
{
var memberId = ((Dictionary<string,object>)(member))["id"].ToString();
var memberName = ((Dictionary<string,object>)(member))["first_name"].ToString();
table.AddRow(memberId+'\t'+memberName);
}
}
}