我有一个像这样的json:
[ [ "Passport Number","NATIONALITY","REASONS" ],[ "SHAIS100","INDIA","" ],[ "","","Agent ID is not matched." ],"" ] ]
我想将其填充到ArrayList< String []>,请告诉我该怎么办?
空字符串不应转换为空.
解决方法
这很简单,您只需要执行以下操作:
1.-首先创建Gson对象:
Gson gson = new Gson();
2.-然后获取您的列表的通讯录类型< String []> (请注意,由于Java的type erasure,您无法像List< String []> .class这样做):
Type type = new TypeToken<List<String[]>>() {}.getType();
3.-最后将JSON解析为类型类型的结构:
List<String[]> yourList = gson.fromJson(yourJsonString,type);