0

I am using vk.com API and in one method in response I am getting something like this:

{
    "ts": 1691519416,
    "updates": [
        [
            6,
            2000000024,
            586731
        ],
        [
            4,
            586732,
            8243,
            2000000024,
            1512642885,
            "income message",
            {
                "from": "384574802"
            }
        ]
    ]
}

The problem is I am using Gson and I don't know what type of array I need to use.

For now I have this:

public class Updates {
    public int ts;
    public Update[] updates;
}

I don`t know what to put inside/instead of updates array.

Found a solution, thank you guys for answers. I just needed to use generics and a 2 dimensional array. The code of Updates class:

public class Updates {
    public int ts;
    public <?>[][] updates;
}
2
  • You should have a bean that is equivalent to this response format Commented Dec 7, 2017 at 10:48
  • I`ll try to use generics, i think it will be good solution Commented Dec 7, 2017 at 11:22

2 Answers 2

1

You can create your class like:

class Response
{
   Timestamp ts;
   Updates[] updates;
}

And use GSON:

Response response = gson.fromJson(jsonString, Response.class);
Sign up to request clarification or add additional context in comments.

2 Comments

What should i put inside updates? That is the question
What method do you call from vk api ? ( maybe it is possible to find something here: github.com/VKCOM/vk-java-sdk )
0

Just need to create a generic array.

private Object<?>[] json;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.