JSON parse error: Unexpected character ('\' (code 92))

Blade 未结 2 4732
ivan_lee
ivan_lee 2020-09-07 10:12

一、该问题的重现步骤是什么?

1. 2.4.0升级2.5.1后

2. 原来的feign接口(用kafka做的一个消息中心,此接口是生成消息提交给kafka供消费者消费)

R MessageProducerVO convertMessageVo
MessageProducerVO MessageProducer = List ListStringString Long Boolean String String

图片.png图片.png

远程调用的时候没用到父类的属性,只有用到如下信息

MessageProducerVO producer = MessageProducerVOproducer.setTopicQueueproducer.setMessageTypeKafkaMsgTypeEnum..ordinalproducer.setSendGroupidList.sendTopicproducer

图片.png

升级过过后 feign接口接收不到提交的数据

报错如下

2020-09-07 09:34:41.723 DEBUG 14072 --- [ XNIO-1 task-20] .c.c.v.BladeRequestMappingHandlerMapping : Mapped to public org.springblade.core.tool.api.R cn.jzcloud.message.feign.MessageClient.sendTopic(cn.jzcloud.message.vo.MessageProducerVO)
2020-09-07 09:34:42.220 ERROR 14072 --- [ XNIO-1 task-20] o.s.c.log.error.RestExceptionTranslator  : 消息不能读取:JSON parse error: Unexpected character ('\' (code 92)): was expecting comma to separate Object entries; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Unexpected character ('\' (code 92)): was expecting comma to separate Object entries
 at [Source: (PushbackInputStream); line: 1, column: 1100] (through reference chain: cn.jzcloud.message.vo.MessageProducerVO["sendGroup"]->java.util.ArrayList[0])

3.


二、你期待的结果是什么?实际看到的又是什么?

目前服务器上回退到2.4.0的版本能正常生产消息  2.4.0 一次成功调用 的日志如下

================  Request Start  ================
===> POST: /client/send_topic Parameters: {"convertMessageVo":{"id":null,"createUser":null,"createDept":null,"createTime":null,"updateUser":null,"updateTime":null,"status":null,"isDeleted":null,"tenantId":null,"templateId":null,"channelId":null,"channelName":null,"message":null,"phone":null,"weChatId":null,"successType":null,"title":null,"messageType":0,"sendType":null,"sendUser":null,"sendAppId":null,"parentSign":null,"failCause":null,"groupType":null,"sendGroup":[{"id":"1302790214144466946","createUser":null,"createDept":null,"createTime":"2020-09-07 10:06:06","updateUser":null,"updateTime":null,"status":null,"isDeleted":null,"source":"速新闻","releaseTime":"2020-09-07 10:01:00","releaseDateTime":null,"releaseDate":"2020-09-07","attribute":null,"region":"230000000000,231100000000","originalLink":"http://www.suxinwen.cn/news/1842939","content":"受降雨影响,水利部门预计辽宁省辽河、浑河、太子河,吉林省第二松花江,黑龙江省嫩江、松花江等河流将出现明显涨水过程,其中辽河上游、嫩江中下游、第二松花江下游、松花江干流等主要江河可能发生超警洪水,暴雨区内部分河流可能发生较大洪水。","taskId":null,"collectionSource":"sina","summary":null,"score":0,"relevance":0,"similarDocsNum":null,"oriId":"15296960","mediaType":"新闻","title":" 做好防汛工作!今年第10号台风“海神”来了","userName":"新华视点微博","authorId":null,"transferContent":"

其他
黑龙江省,嫩江市,黑河市
暴雨,台风,发生
","type":null,"userRegion":null,"userRegionName":"江苏","industry":"其他","formatContent":"受降雨影响,水利部门预计辽宁省辽河、浑河、太子河,吉林省第二松花江,黑龙江省嫩江、松花江等河流将出现明显涨水过程,其中辽河上游、嫩江中下游、第二松花江下游、松花江干流等主要江河可能发生超警洪水,暴雨区内部分河流可能发生较大洪水。","newsImages":null,"isIncident":false,"regionName":null,"html":null,"originalContent":null,"isDeal":null}],"msgProducerIdList":null,"templateSample":null,"isCopyPhone":null,"topicQueue":"jz-cloud-sentiment-brief-incident","signer":null}}
===Headers===  Accept: */*
===Headers===  Connection: Keep-Alive
===Headers===  User-Agent: okhttp/3.14.5
===Headers===  Host: 192.168.20.8:5889
===Headers===  Accept-Encoding: gzip
===Headers===  Content-Length: 11560
===Headers===  Content-Type: application/json;charset=UTF-8
================   Request End   ================

2020-09-07 10:07:36.473  INFO 1 --- [  XNIO-1 task-7] o.s.core.log.aspect.RequestLogAspect     :

================  Response Start  ================
===Result===  {"code":200,"success":true,"data":null,"msg":"操作成功"}
<=== POST: /client/send_topic (1 ms)
================   Response End   ================

三、你正在使用的是什么产品,什么版本?在什么操作系统上?


四、请提供详细的错误堆栈信息,这很重要。


五、若有更多详细信息,请在下面提供。

@FeignClient(
  value = AppConstant.APPLICATION_DESK_NAME
)
public interface INoticeClient {

  String API_PREFIX = "/client";
  String TOP = API_PREFIX + "/top";
  String JSON = API_PREFIX + "/json";

  /**
   * 获取notice列表
   *
   * @param number
   * @return
   */
  @GetMapping(TOP)
  R> top(@RequestParam("number") Integer number);

  /**
   *
   * @param producer
   * @return
   */
  @PostMapping(JSON)
  R json(@RequestBody MessageProducerVO producer);

}
@ApiIgnore()
@RestController
@AllArgsConstructor
public class NoticeClient implements INoticeClient {

  private final NoticeMapper mapper;

  @Override
  @GetMapping(TOP)
  public R> top(Integer number) {
     return R.data(mapper.topList(number));
  }

  @Override
  @PostMapping(JSON)
  public R json(@RequestBody MessageProducerVO producer){
     System.out.println(JsonUtil.toJson(producer));
     return R.data(producer);
  }
}

经仔细排查发现,2.5.1解析不了如下字符串  原2.4.0可以

"      其他
   
    黑龙江省,嫩江市,黑河市
  
   暴雨,台风,发生 
          0\">    默认收藏夹         0\">    默认素材库           短信下发     邮件下发     下发     QQ下发                拷贝地址     一键复制                   删除信息     删除信息并排除来源       "

原请求数据json如下:

 {"id":null,"createUser":null,"createDept":null,"createTime":null,"updateUser":null,"updateTime":null,"status":null,"isDeleted":null,"tenantId":null,"templateId":null,"channelId":null,"channelName":null,"message":null,"phone":null,"weChatId":null,"successType":null,"title":null,"messageType":0,"sendType":null,"sendUser":null,"sendAppId":null,"parentSign":null,"failCause":null,"groupType":null,"sendGroup":[{"id":"1302790214144466946","createUser":null,"createDept":null,"createTime":"2020-09-07 10:06:06","updateUser":null,"updateTime":null,"status":null,"isDeleted":null,"source":"速新闻","releaseTime":"2020-09-07 10:01:00","releaseDateTime":null,"releaseDate":"2020-09-07","attribute":null,"region":"230000000000,231100000000","originalLink":"http://www.suxinwen.cn/news/1842939","content":"受降雨影响,水利部门预计辽宁省辽河、浑河、太子河,吉林省第二松花江,黑龙江省嫩江、松花江等河流将出现明显涨水过程,其中辽河上游、嫩江中下游、第二松花江下游、松花江干流等主要江河可能发生超警洪水,暴雨区内部分河流可能发生较大洪水。","taskId":null,"collectionSource":"sina","summary":null,"score":0,"relevance":0,"similarDocsNum":null,"oriId":"15296960","mediaType":"新闻","title":" 做好防汛工作!今年第10号台风“海神”来了","userName":"新华视点微博","authorId":null,"transferContent":"      其他       黑龙江省,嫩江市,黑河市     暴雨,台风,发生           0\">    默认收藏夹         0\">    默认素材库          
      
      
      
2条回答
提交回复