[Catalyst] Catalyst::Controller:REST and JSON vs JSONP issue
James Spath
jspath at pangeamedia.com
Wed Aug 24 16:00:03 GMT 2011
So it turns out there are certain characters that are perfectly legal
JSON that are NOT legal JavaScript:
http://timelessrepo.com/json-isnt-a-javascript-subset
We have run into this problem in our application which uses
Catalyst::Controller::REST to output certain data as JSON or JSONP.
Catalyst::Controller::REST first encodes the data as JSON, and then to
create JSONP, simply wraps the JSON in a callback function, and no
attempt is made to deal with possible illegal characters.
I believe a solution would involve replacing the illegal characters in
Catalyst::Action::Serialize::JSON before the string is wrapped in the
callback function.
Has anyone else run into this problem?
Thanks!
Jim
More information about the Catalyst
mailing list