fastjson解析巢狀泛型
阿新 • • 發佈:2018-12-26
/** * author zoush * CreateTime 2017-06-03 16:01 * 直接上虛擬碼 */ public class Outer<T> { public String filed3 ; public Inner inner ; public List<T> data; } class Inner{ public String filed ; public int filed2; } /** 泛型類 */ class Fx{ public String filed4 ; public intfiled5; }
String jsonStr = "{\"filed3\":\"111\"," + "\"data\":[{\"filed4\":\"111\",\"filed5\":222},{\"filed4\":\"333\",\"filed5\":444},{\"filed4\":\"555\",\"filed5\":666}]," + "\"inner\":{\"filed\":\"777\",\"filed2\":8888}}"; Outer<Fx> outer = JSON.parseObject(jsonStr,new TypeReference<Outer<Fx>>(){});