java使用hutool JSONUtiltoListjson字符串数组转ListlistString
可以使用Hutool工具类中的JSONUtil和ListUtil来实现将JSON字符串数组转换为List<List
import cn.hutool.json.JSONUtil;
import cn.hutool.core.collection.ListUtil;
import java.util.List;
public class Test {
public static void main(String[] args) {
String jsonStr = "[[\"A\", \"B\", \"C\"], [\"D\", \"E\", \"F\"]]";
List<List<String>> resultList = ListUtil.toList(JSONUtil.parseArray(jsonStr, List.class, String.class));
System.out.println(resultList);
}
}
解析过程中,首先使用JSONUtil.parseArray方法将JSON字符串转换为List<List
原文地址: https://www.cveoy.top/t/topic/brds 著作权归作者所有。请勿转载和采集!