json使用的是fastjson,json转换对象的时候,如果对象中存在泛型对象,则需要特殊处理下才能正常转换。 使用的是fastjson中的TypeReference A<B<C>> resultObj =JSON.parseObject("转换json",new TypeReference<A<B<C>>>(){}); *A为接收类型,B为A的泛型类,C为B的泛型类...
public static void main(String[] args) { UserDto userDto=new UserDto("test","14"); Result<UserDto> user=new Result<>("success","1",userDto); String str=JSON.toJSONString(user); //1 Result<UserDto> result= JSON.parseObject(str,new TypeReference<Result<UserDto>>(){}); //2 Resul...
package com.day13.json; import java.util.*; /** * Author: Json * Date: 2021/10/5 **/ public class TestJson { public static void main(String[] args) { System.out.println("泛型"); //什么是泛型? // 泛型:标签 //指明集合里装的东西 别的东西不让装 声明泛型后 //使用泛型后 这个集...
java中JSON转含泛型对象 public static void main(String[] args) { UserDto userDto=new UserDto("test","14"); Result<UserDto> user=new Result<>("success","1",userDto); String str=JSON.toJSONString(user); //1 Result<UserDto> result= JSON.parseObject(str,new TypeReference<Result<UserDto...
java中JSON转含泛型对象 public static void main(String[] args) { UserDto userDto=new UserDto("test","14"); Result<UserDto> user=new Result<>("success","1",userDto); String str=JSON.toJSONString(user); //1 Result<UserDto> result= JSON.parseObject(str,new TypeReference<Result<UserDto...