androidjsongsonvkvk-sdk

How to serialize the response to object by using Gson?


I make request directly to VK api with token

Like this: https://api.vk.com/method/groups.get?fields=photo_50&access_token=MY_TOKEN&filter=admin%2C%20editor%2C%20moder&extended=1 Here is spec about api But I can't serialize the response to object by using Gson, because is response array there is int value:

{
    "response": [
        2,
        {
            "gid": 59295,
            "name": "Создание",
            "screen_name": "book",
            "is_closed": 0,
            "type": "group",
            "photo_50": "https://pp.userapi.com/qwvD6SPkYzo.jpg"
        },
        {
            "gid": 57150,
            "name": "Массаж",
            "screen_name": "club10450",
            "is_closed": 2,
            "type": "group",
            "photo_50": "https://pp.userapi.com/ZKnmRkS1izs.jpg"
        }
    ]
}

How can I make serialize it to object by using Gson?


Solution

  • Resolved, Added param to url v=5.61 version number

    {
        "response": {
            "count": 190,
            "items": [{
                "id": 28261334,
                "name": "TJ",
                "screen_name": "tj",
                "is_closed": 0,
                "type": "page",
                "is_admin": 0,
                "is_member": 1,
                "photo_50": "https://pp.vk.me/...f2c/06crfCSL1KY.jpg"
                }]
        }
    }