struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mael Le Guével <leguevel.m...@gmail.com>
Subject JSONValidationInterceptor and quotes
Date Tue, 09 Apr 2013 06:50:46 GMT
Hello there,
I am using struts JSON plugin to do some ajax requests. And I am
facing a problem with
org.apache.struts2.json.JSONValidationInterceptor.
Everything works fine as long as my validation error messages do not
contain single quotes. When there are quotes, the client side library
"crashes" because it does not seem to be able to parse the generated
JSON. Here is the JSON:
{
    "fieldErrors": {
        "password": [
            "Password isn\'t correct"
        ]
    }
}

The problem comes from the escaped quote. Apparently, not all JSON
implementations accept escaped single quotes.
I can get rid of the client side error by creating a new interceptor,
inheriting from org.apache.struts2.json.JSONValidationInterceptor, and
overriding the buildResponse(ValidationAware) function to not escape
single quotes. But that does not seem to be a good solution in the
long run. Does someone have a better solution?

Thank you :)

Mael.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message