Wednesday, March 25, 2015

Grails JSON encoding applyCodec

I had some data that I wanted to render in the GSP page, however, by default single quotes were being encoded as

"


To prevent grails from encoding your output, wrap it in the undocumented  applyCodec tag as follows:


var selectedItems = <g:applyCodec encodeAs="none">${data as grails.converters.JSON}</g:applyCodec>

Reference:


http://aruizca.com/how-to-render-json-properly-without-escaping-quotes-inside-a-gsp-script-tag/

No comments:

Post a Comment