php反序列化java.long,JSON反序列化投掷例外 - 无法反序列化的java.util.ArrayList实例出来START_OBJECT令牌...

The below is my JSON response,

Caused by: com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token

at [Source: java.io.PushbackInputStream@bce1d9; line: 1, column: 556] (through reference chain: com.totalHours["data"]->com.totalHours["hourly_totals"])

"totalHours":

{

"hourly_totals":

{

"2013112101":

{

"distance": 1324,

"calories": 90.0120018125,

"steps": 1603,

"active_time": 793,

"inactive_time": 220,

"longest_active_time": 302,

"longest_idle_time": 780

},

"2013112101":

{

"distance": 626,

"calories": 47.0120018125,

"steps": 455,

"active_time": 246,

"inactive_time": 260,

"longest_active_time": 203,

"longest_idle_time": 650

},

... more hours ...

}

I have took a pojo class like below, I am getting an exception when I try to deserialize the my json data.

public class totalHours{

private List hourly_totals;

}

But, I don't know whether to take a List because there is no array in response. What will be the other options to try out for.

解决方案

hourly_totals is an object from an hour represented as a string to another object, to Map , where T is a POJO class representing the data for one hour, would look like a natural choice.

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值