[comment: httpmessagenotreadableexception: JSON parse error: invalid UTF-8 start byte 0xa0]

In these two days, a simple and small requirement was developed iteratively. The post request received the parameters from the front end and converted the received JSON format into the corresponding POJO. However, the program reported the following exceptions in the process of receiving the request:

org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Invalid UTF-8 start byte 0xa0; nested exception is com.fasterxml.jackson.core.JsonParseException: Invalid UTF-8 start byte 0xa0 at [Source: [email protected]; line: 1, column: 61]

And because the front-end code has not been tested in the test environment, because it is tested using postman, 500 system abnormal error messages also appear in postman.

After a long time of searching on the Internet, I tried to set the content type attribute of the request response header, but it didn’t work and still reported an error;

After that, we also carefully checked whether there was a problem in the code, checked the @ requestbody annotation to receive JSON format data and convert it into the corresponding POJO, and the field properties are correct;

Finally, it is found in some blogs that it may also be the reason for Chinese spaces in JSON data, which is inspired.

After checking, use postman tool to select JSON strings with the same format, and the cursor will be displayed together. It is found that individual characters of Queshi do not correspond completely.

Check the corresponding sample

There is no exact correspondence

After modification

Test, success

In fact, it can also be seen from the error message that it is a JSON parsing error, which roughly means that it is an invalid Chinese byte at the beginning.

Read More: