Encoding in Javascript

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Encoding in Javascript

cld71
Having trouble with thymeleaf encoding javascript data coming from a data model object.
As an example in my data model I have the following:
data.setMyJsonData("{\"page\":1, \"mydata\":\"testing\"}");
When I use the following on the thymeleaf template:
<script>var myJsonData=[[${data.myJsonData}]];</script>I get the following output:
<script>var myJsonData={&quot;page&quot;:1, &quot;mydata&quot;:&quot;testing&quot;};</script>
Is there anyway to fix this so it doesn't encode the quotes?