JSON parse error: Can not deserialize instance of java.lang.String out of START_OBJECT token; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of j
异常信息如下:
JSON parse error:
Can not deserialize instance of java.lang.String out of START_OBJECT token;
nested exception is com.fasterxml.jackson.databind.JsonMappingException:
Can not deserialize instance of java.lang.String out of START_OBJECT token
at [Source: java.io.PushbackInputStream@7d1ef454; line: 1, column: 39]
(through reference chain: com.chehejia.aisp.core.result.Result["data"])
我自己的服务去调用别人的服务的时候出现的异常,意思是JSON解析失败,用String类型无法序列化Json对象,先看代码:
三方服务:
@ApiOperation("下订单")
@PostMapping("/orders")
@ApiResponses({
@ApiResponse(code = MusicCode.MUSIC_VIP_PRODUCT_NOT_EXIST_CODE, message = MusicCode.MUSIC_VIP_PRODUCT_NOT_EXIST_DESC),
@ApiResponse(code = MusicCode.MUSIC_VIP_ORDER_CODE_IS_REPEAT_CODE, message = MusicCode.MUSIC_VIP_ORDER_CODE_IS_REPEAT_DESC)}
)
public Result<String> addOrders(@Valid @RequestBody OrderForm form) {
VipProduct vipProduct = vipService.getVipProductByProdCode(form.getProdCode());
if(vipProduct==null){
return Results.failure(MusicCode.MUSIC_VIP_PRODUCT_NOT_EXIST);
}
我的代码:
/**
* @Author: 保密哈哈
* @Description:
* @Date: 2019/6/4 15:40
* @Modified By:
*/
@FeignClient("保密-保密-hmi")
public interface CompensationOrderService {
/**
* 音乐服务下单
* @param form
* @return
*/
@PostMapping(value = "/保密/保密/保密/orders")
@ResponseBody
Result<String> addOrders(@Valid @RequestBody OrderForm form,
@RequestHeader(value = "保密-Token")String token,
@RequestHeader(value = "X-保密-Deviceid")String deviceid);
因为我是通过Fegin调用另一方服务,因为另一个服务调用的接口的返回参数是 Result<String>,所以,我保持了我的接收参数是 Result<String>, 我天真的认为只要完全保持一致就可以,实际上是不行的,传过来的是个Json,所以String是无法解析的,除非是JSon形式的字符串,可行的方法是先用超类Object看看能否接收,并且接收到的是什么参数,然后再解析。
JSON parse error: Can not deserialize instance of java.lang.String out of START_OBJECT token; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of j的更多相关文章
- JSON parse error: Cannot deserialize instance of `int` out of START_OBJECT token; nested exception is com.fasterxml.jackson.databind.exc
代码程序: @PostMapping("selectById") @ResponseBody public Result selectById(@RequestBody int i ...
- Jackson错误:Can not deserialize instance of java.lang.String out of START_OBJECT token
org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: Can not des ...
- HttpMessageNotWritableException: Could not write JSON: Infinite recursion (StackOverflowError); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Infinite
org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: Infinite r ...
- 解决用户自生成meta导入kylin后报错问题Can not deserialize instance of java.lang.String[] out of VALUE_STRING token
报错栈: -- ::, ERROR [http-bio--exec-] cube.CubeManager: : Error during load cube instance, skipping : ...
- Could not read document: Can not deserialize instance of java.lang.String out of START_ARRAY
线上问题: { "timestamp": "1544510665", "status": 400, "error": & ...
- 记一次接口调试错误: {"timestamp":"2019-09-11T03:04:30.036+0000","status":500,"error":"Internal Server Error","message":"Could not write JSON: Object is null; nested exception is com.fasterxml.jackson
接口测试中用postman测试返回是正常的,但是使用其他人去调用就出错了,找了半天,才想起来使用了nginx,用于端口的代理转发.然后根据错误信息发现json格式的某个字段为null,结合日志中的报文 ...
- 400 bad Request: JackSon将json串转成List<Object>,异常com.fasterxml.jackson.databind.JsonMappingException
最近遇到的400, 以前总以为 400 就是参数不匹配造成的,直到今天遇到这个问题 控制台报错如下: com.fasterxml.jackson.databind.JsonMappingExcept ...
- JSON parse error: default constructor not found. class java.time.YearMonth; nested exception is com.alibaba.fastjson.JSONException: default constructor not found. class java.time.YearMonth
java8新出的YearMonth可以方便的用来表示某个月.我的项目中使用springmvc来接收YearMonth类型的数据时发现 x-www-from-urlencoded 格式的数据可以使用&q ...
- Json解析异常处理方式(JSONException: Value of type java.lang.String cannot be converted to JSONObject)
有一次从服务器解析获取到的Json字符串突然报了这个异常,由于这个json是从 php页面上推送过来的,当时就查是不是由于编码问题引起的,所以就上网搜了,网上大部分都是说由于utf-8的bom头引起的 ...
随机推荐
- Building a Service Mesh with HAProxy and Consul
转自:https://www.haproxy.com/blog/building-a-service-mesh-with-haproxy-and-consul/ HashiCorp added a s ...
- pgloader 学习(五)pgloader 参考手册
pgloader将各种来源的数据加载到PostgreSQL中.它可以转换动态读取的数据,并在加载前后提交原始SQL. 它使用COPY PostgreSQL协议将数据流式传输到服务器,并通过填充一对re ...
- Android入门教程(八)
关注我,每天都有优质技术文章推送,工作,学习累了的时候放松一下自己. 本篇文章同步微信公众号 欢迎大家关注我的微信公众号:「醉翁猫咪」 今天讲讲安卓入门(八),讲讲Android的简介,如何搭建An ...
- Apache2 服务配置 ubuntu16.04 + django1.11
(步骤) 环境 Ubuntu 16.04 Python 3.5.2 Django 1.11 Apache 2.4 1.Apache2安装 sudo apt-get install apache2 查看 ...
- OpenFOAM——具有压差且平行平板间具有相对运动流动
本算例翻译整理自:http://the-foam-house5.webnode.es/products/chapter-1-plane-parallel-plates-case/ 这个算例中两平板间具 ...
- ICEM-实验环
原视频下载地址:https://pan.baidu.com/s/1eSbxiO6 密码: 7114
- 用DLL方式封装MDI子窗体
用DLL方式封装MDI子窗体是一种常用的软件研发技术,他的长处: 研发人员能够负责某一个模块的编写包括(界面+逻辑),能够互不干扰,模块研发完成后,主程式统一调用. 易于程式升级,当程式升级时,不用编 ...
- PostgreSQL中的The Oversized-Attribute Storage Technique(TOAST:超大属性存储技术)
PostgreSQL使用固定的页面大小(通常为8kB),并且不允许元组跨越多个页面.因此,不可能直接存储非常大的字段值.为了克服这种限制,将大字段值压缩和/或分解成多个物理行.这对用户来说是透明的,对 ...
- nginx日志切割和日志清理
##########################日志切割################################1.上传脚本到/usr/local/nginx/logs/下 2.并附执行权 ...
- odoo开发笔记--form视图按钮样例
如图: 对应后台views视图,class可选内容值: class="oe_highlight" class="btn-xs" class="btn- ...