I get an error:
System.InvalidOperationException: Type 'VK.Response' is not supported for deserialization of an array.
JSON that i get looks like:
{"response":[{"id":269058571,"first_name":"Name","last_name":"LastName","photo_50":"http://ift.tt/1JxM05L"}]}
My method is:
private void getFriendInfo()
{
string method = "users.get";
string param = "user_ids=269058571&fields=photo_50";
string url = "http://ift.tt/1huYTUH" + method + "?" + param + "&v=5.31&access_token=" + key + "";
WebClient client = new WebClient();
string json = client.DownloadString(url);
JavaScriptSerializer json_serializer = new JavaScriptSerializer();
RootObject response = (RootObject)json_serializer.Deserialize(json, typeof(RootObject));
for (int counter = 0; counter < response.response.items.Count; counter++)
{
pictureBox1.Load(response.response.items[counter].photo_50);
}
}
Classes:
class Response
{
public int count { get; set; }
public List<Item> items { get; set; }
}
class RootObject
{
public Response response { get; set; }
}
class Item
{
public string first_name { get; set; }
public string last_name { get; set; }
public string domain { get; set; }
public string photo_50 { get; set; }
}
Aucun commentaire:
Enregistrer un commentaire