'Excluding “ when using StringEscapeUtils.escapeHtml4

I am trying to Sanitize the requestBody. For this purpose I am converting Object to Json and then passing the Json to

requestBody

{
  "data": {
    "id": "123",
    "unit_id": "456",
    "country": "jp",
    }
}

StringEscapeUtils.escapeHtml

Output post escaping:

{"data":{"id":"123","unit_id":"456","country":"jp"}}

It is escaping the double quotes(“) which is breaking the Json structure when I am trying convert the Json back to Object.

How I can exclude double quotes(“) alone during this process?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source