
public static void main(String[] args) {
CommonQueryVO commonQueryVO1 = new CommonQueryVO();
commonQueryVO1.setLabel("1");
commonQueryVO1.setValue("2");
CommonQueryVO commonQueryVO2 = new CommonQueryVO();
commonQueryVO2.setLabel("1");
commonQueryVO2.setValue("2");
List<CommonQueryVO> list = new ArrayList<>();
list.add(commonQueryVO1);
list.add(commonQueryVO2);
//实体转json
String s = JsonUtils.objectToString(commonQueryVO1);
System.out.println(s);
String s1 = JSONObject.toJSONString(commonQueryVO1);
System.out.println(s1);
//json转实体
JSONObject jsonObject = JSONObject.parseObject(s1);
CommonQueryVO commonQueryVO3 = JSONObject.parseObject(s1, CommonQueryVO.class);
System.out.println(jsonObject);
System.out.println(commonQueryVO3);
//list转json
String s2 = JsonUtils.objectToString(list);
System.out.println(s2);
String s4 = JSONObject.toJSONString(list);
System.out.println(s4);
List<Map<String,Object>> list3 = new ArrayList<>();
Map<String,Object> map = new HashMap<>();
map.put("lable", "1");
list3.add(map);
String s3 = JSONArray.toJSONString(list3);
System.out.println(s3);
//json转list
JSONArray jsonArray = JSONArray.parseArray(s2);
System.out.println(jsonArray);
List<CommonQueryVO> list1 = JSONArray.parseArray(s2, CommonQueryVO.class);
System.out.println(list1);
JSONArray jsonArray1 = JSONArray.parseArray(s3);
//报黄
List<Map<String,Object>> list4 = (List<Map<String,Object>>)JSONArray.parse(s3);
System.out.println(jsonArray1);
//报黄
List<Map> maps = JSONArray.parseArray(s3, Map.class);
System.out.println(maps);
//报黄
List<Map<String,Object>> list2 = JSONArray.parseObject(s3, List.class);
System.out.println(list2);
}

【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
· SQL Server 2025 AI相关能力初探