数组字符串转数组
String str = "[262698, 262699, 262701]";
Integer[] integers = JSON.parseObject(str, Integer[].class);
//二维数组字符串转二维数组
String str = "[[262698, 262699, 262701], [262698, 262699, 262889], [262698, 262699, 263058]]";
Integer[][] cityIds = JSON.parseObject(str, Integer[][].class);
//数组字符串转LIST
String str = "[262698, 262699, 262701]";
List<Integer> integers = JSON.parseObject(str, new TypeReference<List<Integer>>() {});
//二维数组字符串转LIST
String str = "[[262698, 262699, 262701], [262698, 262699, 262889], [262698, 262699, 263058]]";
List<List<Integer>> integers = JSON.parseObject(str, new TypeReference<List<List<Integer>>>() {});
文章介绍了如何在Java中使用JSON库将字符串转换为数组和列表。示例包括从JSON字符串到Integer数组、二维Integer数组以及Integer的List和二维IntegerList的转换方法。
1597

被折叠的 条评论
为什么被折叠?



