如何将Json数组字符串转化为Json的List

如题所述

将json字符串转成Java的Array数组
private String json = "{\"address\":\"chian\",\"birthday\":{\"birthday\":\"2010-11-22\"},"+
"\"email\":\"[email protected]\",\"id\":22,\"name\":\"tom\"}";

@Test
public void readJSON2Array() {
try {

json = "[" + json + "]";
jsonArray = JSONArray.fromObject(json);

Object[] os = jsonArray.toArray();
System.out.println(os.length);

Student[] stus = (Student[]) JSONArray.toArray(jsonArray, Student.class);
System.out.println(stus.length);
System.out.println(stus[0]);
} catch (Exception e) {
温馨提示:答案为网友推荐,仅供参考