Double quotes in Json String replaced in freemarker file
In an action class, I get a list of beans in conventional manner. Then I use Gson to convert this object list in a json string. This works well (as you can see as follow):
"{ "employees" : [{ "firstName":"John" , "lastName":"Doe" }, {"firstName":"Anna" , "lastName":"Smith" } , { "firstName":"Peter" , "lastName":"Jones" } ]}";
Finally, in my freemarker file I get this variable (String JSon) but, in it, all double quotes have been replaced with '& quote;'.
<@sjg.grid id="gridtable"
caption="My title"
dataType="json"
href="${remoteurl}"
pager="true"
gridModel="${employeesInJsonString?js_string}"
rowList="10,15,20"
rowNum="15"
rownumbers="true">
<sjg:gridColumn name="firstName" index="firstName" title="FirstName" sortable="false"/>
<sjg:gridColumn name="lastName" index="lastName" title="LastName" sortable="false"/>
The resulting String is the following:
"{ & quote;employees& quote; : [{ & quote;firstName& quote;:& quote;John& quote; , & quote;lastName& quote;:& quote;Doe& quote; }, {& quote;firstName& quote;:& quote;Anna& quote; , & quote;lastName& quote;:& quote;Smith& quote; } , { & quote;firstName& quote;:& quote;Peter" , & quote;lastName& quote;:& quote;Jones& quote; } ]}";
How to keep out this transformation?
PS: I already tried to prefix all double quotes by a backslash to escape the character but the result is the same (resultJsonString = jsonString.replaceAll(""", """)).
Thank you in advance for your help
链接地址: http://www.djcxy.com/p/37862.html上一篇: 我是否需要为json对象转义任何字符?