java float 不能序列化_無法從VALUE_NUMBER_FLOAT標記中反序列化java.sql.Timestamp的實例...

I have a RESTful API on Jersey 2.17 with Jackson on JDK8. It is JSON style API. This API accepts a Java object, it has this field:

我在Jersey 2.17上有一個RESTful API,Jackson在JDK8上。它是JSON樣式的API。此API接受Java對象,它具有以下字段:

@JsonProperty("processEndTime")

public Timestamp getRunDate() {

return runDate;

}

@JsonProperty("processEndTime")

public void setRunDate(Timestamp runDate) {

this.runDate = runDate;

}

Now when I submit a small number, it works perfectly like this:

現在,當我提交一個小數字時,它的工作原理如下:

"processEndTime" : 1434989360,

But it fails when the number is big one, like this:

但是當數字很大時它會失敗,如下所示:

"processEndTime" : 1434989360380,

The most weird thing is that I had a Jmeter test case, it sent the exact the same big number, it can pass without any issues. I can verify this number on the server side and confirmed it is correctly passed.

最奇怪的是我有一個Jmeter測試用例,它發送了完全相同的大數字,它可以毫無問題地通過。我可以在服務器端驗證此號碼並確認它已正確通過。

The full error message is:

完整的錯誤消息是:

Can not deserialize instance of java.sql.Timestamp out of VALUE_NUMBER_FLOAT token at [Source: org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream@23117fbd; line: 1, column: 562] (through reference chain: com.abc.api.dto.MyClassA["processEndTime"])

無法在[來源:org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream@23117fbd;中刪除VALUE_NUMBER_FLOAT令牌中的java.sql.Timestamp實例。 line:1,column:562](通過參考鏈:com.abc.api.dto.MyClassA [“processEndTime”])

Any suggestions?

有什么建議么?

1 个解决方案

#1

0

I figure out the issue:

我弄清楚了這個問題:

I did some converting in the request data:

我在請求數據中做了一些轉換:

JSONObject analysis = new JSONObject(templateAnalysis3);

data = analysis.toString();

this toString function will convert long number to E format:

這個toString函數會將長數轉換為E格式:

1434989360380 -> 1.43498936038E12

This E format is not supported and caused this failure.

不支持此E格式並導致此失敗。

I fixed it by using templateAnalysis3 directly:

我直接使用templateAnalysis3修復了它:

data = templateAnalysis3;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值