小猴在封装数据的时候,是从大往小的封装
首先在获取数据集合之前
1:创建最外层的POJO 封装类/
fuDemo fuDemo = new fuDemo();
2:创建第二层pojo封装实体类
ziDemo ziDemo =new zi Demo();
fuDemo.oneList(ziDemo);
fuDemo.twoList(ziDemo);
fuDemo.threeList(ziDemo);
ziDemo.setId(1);
ziDemo.setName("张三");
ziDemo.setBananaList(bananaList);
ziDemo.setAppleList(appleList);
ziDemo.setPearList(pearList);
{
oneList.{
id:1,
name:张三,
bananaList{id,name};
appleList{id,name};
pearList{id,name};
}
twoList{
id:2,
name:李四,
bananaList{id,name};
appleList{id,name};
pearList{id,name};
}
threeList{
id:3,
name:王五,
bananaList{id,name};
appleList{id,name};
pearList{id,name};
}
}
基本上就是这样的,如果出现$ref 对象地址值引用, ,可以在controller 中将Json数据转换成 Json字符串,再转成Json对象就好了 .
______________________________________________
以下是封装实体类:
---------------------------------------------------------------------------
public class fuDemo implements Serializable{ private static final long serialVersionUID= 8239617416787276350L;(当出现序列化接口.网络上的与本地不一致时候//解决办法) private List<ziDemo> oneList; private List<ziDemo> twoList; private List<ziDemo> threeList; get/set/............... } --------------------------------------------------------------------------- public class ziDemo implements Serializable{ private Long Id; private String name; private List<banana> bananaList; private List<apple> appleList; private List< pear> pearList; get/set/............... }
---------------------------------------------------------------------------
public class banana implements Serializable{
private Long Id;
private String name;
get/set/...............
}
public class apple implements Serializable{
get/set/...............
}
public class pear implements Serializable{
get/set/...............
}
---------------------------------------------------------------------------