com.fasterxml.jackson.core.JsonParseException
今天测试遇到以上的错误信息。
org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Unexpected character ('"' (code 34)): was expecting comma to separate Object entries; nested exception is com.fasterxml.jackson.core.JsonParseException: Unexpected character ('"' (code 34)): was expecting comma to separate Object entries
at [Source: java.io.PushbackInputStream@4f800344; line: 21, column: 4]
at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.readJavaType(AbstractJackson2HttpMessageConverter.java:238)
at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.read(AbstractJackson2HttpMessageConverter.java:223)
at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver.readWithMessageConverters(AbstractMessageConverterMethodArgumentResolver.java:201)
其实我们看错误的提示已经很明白了,当Json 转换的时候出现了异常。
什么的情况下会出现如下的错误呢?
不是标注的Json格式。
- 包含特殊符号
- 字符串引号缺失
- 缺少逗号
- 等等
只要不是标准的Json格式都会遇到上面的异常信息。