我不知道如何使用 Gson 反序列化 JSON 对象内的数组。我试图反序列化的 json 对象如下所示:
{"item0":3,
"item1":1,
"item2":3,
"array":[
{"arrayItem1":321779321,
"arrayItem2":"asdfafd",
"arrayItem3":"asasdfadf"}]}
我设法构建了一个如下所示的类:
public class Watchlist {
private int itemn0;
private int itemn1;
private int itemn2;
private Object array;
}
但是当 gson 尝试反序列化数组时,它会抛出异常:
com.google.gson.JsonParseException: Type information is unavailable, and the target object is not a primitive: <my gson array>
有人可以告诉我如何反序列化吗?