java - Gson gives "unchecked conversion" warning -
i trying convert json strings objects this:
string jsonstring = "[\"string1\", \"string2\"]"; gson gson = new gson(); list<string> list = gson.fromjson(jsonstring, list.class);
there warning:
warning: [unchecked] unchecked conversion list = gson.fromjson(jsonstring, list.class); ^ required: list<string> found: list
i tried use list<string>.class
instead of list.class
compile time error saying can't that...
how can rid of warning?
you can use 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);
Comments
Post a Comment