jackson 序列化一个类怎么能生成多种JSON
java
public class Board { private Integer boardId; private Integer userId; private String title; private String description; private String categoryId; private int seq; private long pinCount; private long followCount; private long likeCount; private long createdAt; private long updatedAt; private int deleting; private int isPrivate; private Object extra; private List<Pin> pins; private User user; }
比如上面 Board
类
格式一: json
:
json
{ "board_id": 18523725, "user_id": 12314505, "title": "室内软装之儿童房", "description": "", "category_id": "home", "seq": 18523725, "pin_count": 153, "follow_count": 81, "like_count": 7, "created_at": 1416270907, "updated_at": 1419990698, "deleting": 0, "is_private": 0, "extra": null, "pins": [], "user": {} }
格式二: json
:
json
{ "board_id": 18523725, "user_id": 12314505, "title": "室内软装之儿童房", "description": "", "category_id": "home", "seq": 18523725, "pin_count": 153, "follow_count": 81, "like_count": 7, "created_at": 1416270907, "updated_at": 1419990698, "deleting": 0, "is_private": 0 }
格式三: json
:
json
{ "board_id": 18523725, "user_id": 12314505, "title": "室内软装之儿童房", "description": "", "category_id": "home" }
等等。。。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过
filter
过滤字段可以达到这个目的参考:http://stackoverflow.com/questions/13764280/how-do-i-exclude-fields-with-jackson-not-using-annotations