Gson gives "unchecked conversion" warning
gson, java, json
Solution
You can use an array
String[] array = gson.fromJson(jsonString, String[].class);
or using `TypeToken`
Type listType = new TypeToken<ArrayList<String>>() {}.getType();
List<String> list = gson.fromJson(jsonString, listType);
Problem
I was trying to convert json strings to objects like this: ``` String jsonString = "[\"string1\", \"string2\"]"; Gson gson = new Gson(); List<String> list = gson.fromJson(jsonString, List.class); ``` There was this warning: ``` warning: [unchecked] unchecked conversion list = gson.fromJson(jsonString, List.class); ^ required: List<String> found: List ``` I tried to use `List<String>.class` instead of `List.class` but I get a compile time error saying that I can't do that... How can I get rid of this warning?