You are trying to create an object without an array (Collection) from a JSONArray. The error is pretty clear: GSON was expecting the beginning of the object, but instead found the beginning of the array.
Take a look at the documentation page below to learn how to work with arrays and collection types using GSON
Array Examples
Gson gson = new Gson (); int [] ints = {1, 2, 3, 4, 5}; String [] strings = {"abc", "def", "ghi"};
(Serialization) gson.toJson (ints); ==> fingerprints [1,2,3,4,5] gson.toJson (strings); ==> prints ["abc", "def", "ghi"]
(Deserialization) int [] ints2 = gson.fromJson ("[1,2,3,4,5]", INT [] class). ==> ints2 will be the same as ints
We also support multidimensional arrays with arbitrarily complex element types. Collection examples
Gson gson = new Gson (); Collection ints = Lists.immutableList (1,2,3,4,5);
(Serialization) String json = gson.toJson (ints); === json is [1,2,3,4,5]
(Deserialization) type collectionType = new TypeToken> () {} GetType (). Collection ints2 = gson.fromJson (json, collectionType); ints2 is the same as ints
Pretty disgusting: note how we determine the type of collection Unfortunately, there is no way around this in Java
Collection Limitations
It can serialize a collection of arbitrary objects, but cannot deserialize from it. Because there is no way to tell the user the type of the resulting object. Upon deserialization, the collection must have a specific generic type. All of this makes sense and is rarely a problem w> if you follow good Java coding practices.