I am attempting to escape a string in a JSP to return valid JSON on an AJAX call however the spring:escapeBody tag is not correctly escaping single quotes for JSON. Valid JSON s
The Javascript Object Notation specification states that
Any character may be escaped.
As such,
{
"status": "success",
"body" : "if you don\'t have \"user\" an account"
}
is valid JSON.
If you need to create really custom text, you'll need to generate it yourself in a controller handler method or other component.
Ideally, you would use a @ResponseBody
annotated method with a POJO that represents your status/body JSON object.