求助:alibaba.fastjson把list转成string有问题,漏掉了Long类型的属性

时时刻刻看着自己的心 2015-07-16 09:28:57
List<SocExternalInfo> resultList = financialPlannerPCService.queryExternalListByDate(queryParam);
好几个Long类型的属性是有值的



String JSONString = JSON.toJSONString(resultList, true);
但是转成json后,字段消失了,除了ID之外,所有Long类型的属性都消失了。
[
{
"accountNo":"111111",
"accountStatus":"0",
"activeCode":"001",
"activeName":"001",
"id":11,
"idNumber":"371184198610192715 ",
"invitationChannel":"2",
"ip":"127.0.0.1",
"isPurchasePrd":"0",
"recommendNature":"1",
"recommendedTime":1435649710000,
"recommendedTimeStr":"2015-06-30 15:35:10",
"updateTime":1435649750000,
"userName":"l111111n@163.com"
},
{
"accountNo":"1777777",
"accountStatus":"0",
"activeCode":"001",
"activeName":"001",
"id":17,
"idNumber":"371184198610192715 ",
"invitationChannel":"2",
"ip":"127.0.0.1",
"isPurchasePrd":"0",
"recommendNature":"1",
"recommendedTime":1435649710000,
"recommendedTimeStr":"2015-06-30 15:35:10",
"updateTime":1435649750000,
"userName":"l1777777n@163.com"
},
............................
]

bean的Long属性部分如下:
/**
* 首笔金额
**/
@Column(name = "FIRST_AMOUNT")
private Long firstAmount;

/**
* 购买总金额
**/
@Column(name = "PURCHASE_TOTAL_AMOUNT")
private Long purchaseTotalAmount;

/**
* 用户给理财师带来佣金总额
**/
@Column(name = "CONTRIBUTION_AMOUNT")
private Long contributionAmount;

/**
* @return the contributionAmount
*/
public Long getContributionAmount() {
return contributionAmount;
}

/**
* @param contributionAmount the contributionAmount to set
*/
public void setContributionAmount(Long contributionAmount) {
this.contributionAmount = contributionAmount;
}
...............................................

请问这是怎么回事?
...全文
809 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
风过无痕1110 2015-07-16
  • 打赏
  • 举报
回复
最近正好用fastjson,我试了下,Long类型是可以的,你确定你的方式是正确的? 我的版本
<dependency>
			<groupId>com.alibaba</groupId>
			<artifactId>fastjson</artifactId>
			<version>1.2.6</version>
		</dependency>
shixitong 2015-07-16
  • 打赏
  • 举报
回复
引用 2 楼 China_xuelei 的回复:
确定都有值,受这个破工程限制,不好换json工具类。 另外找到了避开的办法,把Long 用 long 就可以转了,但是每个都这样处理也烦人。
那里每个pojo都的改?(如果有Long的话),那你id的类型是Long还是long?
  • 打赏
  • 举报
回复
确定都有值,受这个破工程限制,不好换json工具类。 另外找到了避开的办法,把Long 用 long 就可以转了,但是每个都这样处理也烦人。
shixitong 2015-07-16
  • 打赏
  • 举报
回复
在仔细检查下,确定比如某天记录id的long有值contributionAmount也有值,但是只有id转json的时候有值,contributionAmount没值,如果是这样可以 1、换个名字试试 2、换成其它的json工具类试试,比如Gson这些

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧