小猴在封装数据的时候,是从大往小的封装

首先在获取数据集合之前

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/...............

}

---------------------------------------------------------------------------

 

GitHub 加速计划 / js / json
41.72 K
6.61 K
下载
适用于现代 C++ 的 JSON。
最近提交(Master分支:1 个月前 )
960b763e 3 个月前
8c391e04 6 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐