可以使用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>类型的数据,然后使用ListUtil.toList方法将其转换为List<List>类型的结果。最后,将结果打印出来即可。

java使用hutool JSONUtiltoListjson字符串数组转ListlistString

原文地址: https://www.cveoy.top/t/topic/brds 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录