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 should not escape single quotes.
<%@ page trimDirectiveWhitespaces="true" contentType="json/application"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
{
"status": "success",
"body" : "<spring:escapeBody javaScriptEscape="true">
if you don't have "user" an account
</spring:escapeBody>"
}
so this code evaluates to:
{
"status": "success",
"body" : "if you don\'t have \"user\" an account"
}
but valid JSON needs it to be:
{
"status": "success",
"body" : "if you don't have \"user\" an account"
}
is there anyway I can not escape the single quote with the escapeBody tag? Or is there another tag I can use? maybe a JSTL function?