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头引起的 ... 
随机推荐
- 洛谷 P2212 [USACO14MAR]浇地Watering the Fields 题解
			P2212 [USACO14MAR]浇地Watering the Fields 题目描述 Due to a lack of rain, Farmer John wants to build an ir ... 
- vue data不可以使用箭头函数的问题解析
			这篇文章主要介绍了vue data不可以使用箭头函数问题,本文通过源码解析给大家介绍的非常详细,具有一定的参考借鉴价值,需要的朋友可以参考下 首先需要明确,a() {}和 b: () => {} ... 
- hosts 屏蔽定位域名
			通过修改hosts屏蔽定位服务的域名 #屏蔽百度地图 1.0.0.1 api.map.baidu.com 1.0.0.1 ps.map.baidu.com 1.0.0.1 sv.map.baidu.c ... 
- SpringBoot定时任务@Scheduled
			SpringBoot定时任务主要由两个注解完成. @Scheduled加在方法上面. @EnableScheduling加在类上面.可以是Application类,也可以是@Component类,还可 ... 
- libusb: android上集成libusb库
			1. 下载libusb库. 可以到libusb库的官网(https://libusb.info/)或者是其官方的github仓库(https://github.com/libusb/libusb/re ... 
- np.meshgrid
- h5开发安卓机型点击输入框调起输入法,输入框被键盘遮挡的解决方法
			前言: 从以前的项目中找一个问题的解决方案,顺带找到了这个安卓机型调起输入法,页面没有自动上滑导致输入框被弹起的键盘遮挡的解决方案.这个问题只有安卓机型页面中的输入框处于底部(也就是底部键盘区域)的时 ... 
- ISO/IEC 9899:2011 条款5——环境
			5.环境 1.一个实现在两个不同的数据处理系统环境下分别翻译C源文件与执行C程序,在本国际标准中分别称为翻译环境和执行环境.它们的特征定义并包含了根据顺从标准实现的语法及语义规则所构造的顺从标准的C程 ... 
- H3C Telnet 配置
			Telnet 配置管理方法是网络工程师和网络管理员使用最广泛的一种设备访问控制方法,它通过局域网或广域网实现本地或远程的访问控制,但是它的实验必须要求首先对设备进行初始化配置,否则用户无法正常登录和访 ... 
- FreeSWITCH命令大全
			FreeSWITCH启动.查看.及关闭 FreeSWITCH一般安装在路径 /usr/local/freeswitch ,可执行程序位于/usr/local/freeswitch/bin 下,配置文件 ... 
