JSONObject互转String,JSONArray互转List,list互转String

jsonStr转对象:

Student student = JSON.parseObject(jsonStr,Student.class);

String转JSONObject:

JSONObject jsonObj = JSON.parseObject(str);

JSONObject转String:

String str = JSON.toJSONString(jsonObj);

JSONObject转对象:

Student student = JSONObject.toJavaObject(jsonObj, Student.class);

JSONArray转对象list:

List<Student> studentList = JSONArray.parseArray(jsonArrayStr, Student.class);

list转String:

String ids = StringUtils.join(list,',')

逗号隔开String转list:

List<String> list = Arrays.asList(strings.split(","));
Logo

汇聚全球AI编程工具,助力开发者即刻编程。

更多推荐