java - How to convert string array to object using GSON/ JSON? -
i have json this:
[ [ "passport number", "nationality", "reasons" ], [ "shais100", "india", "" ], [ "", "", "agent id not matched." ], [ "", "", "" ] ]
i want populate arraylist<string[]>
,please tell me how do?
and empty strings should not convert null.
that's simple, need following:
1.- first create gson
object:
gson gson = new gson();
2.- correspondent type
list<string[]>
(note can't list<string[]>.class
due java's type erasure):
type type = new typetoken<list<string[]>>() {}.gettype();
3.- parse json structure of type type
:
list<string[]> yourlist = gson.fromjson(yourjsonstring, type);
Comments
Post a Comment