How to make Jackson to avoid Escaping Backslash

As I tried to deserialize a json string from database with jackson, I received error message like this:

The json string is:

It’s the Backslash in the source json string which lead to the error.

To fix the error, we can take advantage of the config item: ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER.

In the earier versions of jackson, we can config like this:

But in the lastest version(2.11.0), I found the config was moved into the class JsonReadFeature. Em , we need to change the config like this :

If there is already an instance of ObjectMapper, we can create an instance of ObjectReader to execute the work:



Leave a Reply