【bug】Could not write JSON 访问接口报错 代码没有报错

项目场景:

在前端请求接口的时候,报了问题描述中的问题。经过反复排除,因为其他response没有出现这个问题,所以我就把问题定位在response中,最终把目标定位在了这个分页集合的属性上。
response

 	/**
     * 分页集合
     */
    private List<Map<String, String>> pageList;

问题描述:

{
  "timestamp": "2021-12-20T01:26:12.907+0000",
  "status": 500,
  "error": "Internal Server Error",
  "message": "Could not write JSON: Class com.ai.gaimops.log.pojo.entity.Indicatrix not subtype of [map type; class java.util.Map, [simple type, class java.lang.String] -> [simple type, class java.lang.String]]; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Class com.ai.gaimops.log.pojo.entity.Indicatrix not subtype of [map type; class java.util.Map, [simple type, class java.lang.String] -> [simple type, class java.lang.String]] (through reference chain: com.ai.gaimops.log.pojo.response.IndicatrixResponse[\"pageList\"]->com.github.pagehelper.Page[0])",
  "path": "/log/insicatrix/getList"
}

原因分析:

因为报的是json的问题,同时又只有这个属性有返回的时候,才报这个问题,所以很有可能是json里面不能有List吧,于是我就试一下


解决方案:

我就把List< Map>改成了List< Object>

	/**
     * 分页集合
     */
    private Object pageList;

结果就成功了,这个问题感觉不是很常见,也是浪费了我半个小时的时间。

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值