I have an array like this:
[{"poolkost":"IWXI"},{"poolkost":"ILXI"},{"poolkost":"VGXI"}]
and want to put it in a List using the tutorial How to convert JSONArray to List with Gson?
My Code:
String jsonStr = DBFunction.GetBoxer(GlobalClass.DIR);
Gson gson = new Gson();
Type listType = new TypeToken<List<String>>(){}.getType(); //ERROR 1
List<String> PoolList = gson.fromJson(jsonStr, listType); //ERROR 2
I get 2 errors:
Error 1:
Type mismatch: cannot convert from java.lang.reflect.Type to android.renderscript.Type
Error 2:
The method fromJson(String, Class<T>) in the type Gson is not applicable for the arguments (String, Type)
I cannot fix the first Error, either the second...
>(){}.getType();?
– Stan Apr 23 '15 at 19:02>(){}.getType(); seems to be right, and this fixed the second, too.
– zauber3r Apr 23 '15 at 19:02