Json字符串只有数组,而次数组没有名字,如下
[
{
"name": "zhangsan",
"age": "10",
"phone": "11111",
"email": "11111@11.com"
},
{
"name": "lisi",
"age": "20",
"phone": "22222",
"email": "22222@22.com"
},
...
]
public class UserBean {
private String name ;
private String age;
private String phone;
private String email;
//省略get,set方法
...
}
Type listType = new TypeToken<List<UserBean>>() {}.getType();
List<UserBean> users = new Gson().fromJson(userJsonString, listType);
原文:https://www.cnblogs.com/wzqnxd/p/10875787.html