Answer the question
In order to leave comments, you need to log in
How to create a JSON pattern if the parameter name is unknown?
Vkontakte API gives the following JSON result:
{
"response": [
2,
{
"gid": 20629724,
"name": "Habrahabr",
"screen_name": "habr",
"is_closed": 0,
"type": "page",
"is_admin": 0 ,
"is_member": 1,
"photo": "http:\/\/cs625620.vk.me\/v625620167\/2ac9d\/QholHa-tKsI.jpg",
"photo_medium": "http:\/\/cs625620 .vk.me\/v625620167\/2ac9c\/aqvP2mwKWvQ.jpg",
"photo_big": "http:\/\/cs625620.vk.me\/v625620167\/2ac9b\/F1E7HSFXLr0.jpg"
},
{
"gid ": 69578162,
"name": "Habrakon",
"screen_name": "horse_habr",
"is_closed": 0,
"type": "page",
"is_admin": 0,
"is_member": 0,
"photo": "http:\/\/cs606920.vk.me\/v606920089\/500b\/HMVpfZKx_uQ.jpg",
"photo_medium": "http:\/ \/cs606920.vk.me\/v606920089\/500a\/2R8ePCnuhiw.jpg",
"photo_big": "http:\/\/cs606920.vk.me\/v606920089\/5009\/-pPfLgf2oB4.jpg"
}
]
}
JavaScriptSerializer().Deserialize<List<VKPatternGroups>>(JSON);
public class VKPatternGroups
{
public List<VKPatternGroup> response { get; set; } //IList<VKPatternGroup>
}
public class VKPatternGroup
{
public string gid { get; set; }
public string name { get; set; }
public string type { get; set; }
// public string members_count { get; set; }
}
Answer the question
In order to leave comments, you need to log in
Use latest api version not 3.0. Then there will be no such misunderstandings.
v=5.34
https://vk.com/dev/versions
public class VKGroupObject
{
public ResponseGroup response { get; set; }
}
public class ResponseGroup
{
public string count { get; set; }
public IList<VKGroupItems> items { get; set; }
}
public class VKGroupItems
{
public string id { get; set; }
public string name { get; set; }
public string screen_name { get; set; }
public string is_admin { get; set; }
public string admin_level { get; set; }
public string photo_50 { get; set; }
}
public List<T> GetData<T>(string json)
{
List<T> group = new List<T>();
group.Add(JsonConvert.DeserializeObject<T>(json));
return group;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question