无数据头Json字符串
Json字符串只有数组,而次数组没有名字,如下
[
{
"name": "zhangsan",
"age": "10",
"phone": "11111",
"email": "11111@11.com"
},
{
"name": "lisi",
"age": "20",
"phone": "22222",
"email": "22222@22.com"
},
...
]
Json对应的实体类
public class UserBean {
private String name ;
private String age;
private String phone;
private String email;
//省略get,set方法
...
}
Gson解析:字符串转实体类
Type listType = new TypeToken<List<UserBean>>() {}.getType();
List<UserBean> users = new Gson().fromJson(userJsonString, listType);