View Full Version : Ext.data.JsonStore - returned JSON object not valid

25 Feb 2011, 9:33 PM

I am working on a gridpanel and using Ext.data.JsonStore to get the data from a url.

var store = new Ext.data.JsonStore({
root: 'mysList',
totalProperty: 'totalCount',
remoteSort: true,
fields : [ 'id', 'description'],
proxy: new Ext.data.HttpProxy({url: RESULTS_URL, method: 'POST'})
and the url (jsp - struts2) that returns the json object looks like:

"totalCount": "<s:property value="total"/>",
"myList": [
<s:iterator value="myList" status="stat">{
"id":"<s:property value="id"/>",
"description":"<s:property value="description"/>"}<s:if test="!#stat.last">,</s:if>
The 'description' field is a VARCHAR in DB and contains special characters as well as carriage returns. Hence when the response is returned back, the grid is not populated with the data as the json returned is not valid.

Can anyone let me know about how to fix this issue?

Appreciate any help.


26 Feb 2011, 6:21 PM

26 Feb 2011, 11:52 PM
I haven't had this problem with special characters or returns, my first suggestion would be to make sure your character encoding being sent from your server is UTF-8 (and by that I mean the encoding of the http response) and also the charset in your html page by making sure the following is in your header:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

27 Feb 2011, 2:16 PM
I checked your suggestion and everything was good.
I ended up creating a custom tag in struts2 that returns encoded json string.

Thanks for your views ..