| Author |
Struts and JSON
|
Jay Abrahm
Ranch Hand
Joined: May 28, 2008
Posts: 182
|
|
Folks,
I'm not sure if this post goes in here but since it looked like a struts rendering issue that I didn't understand right I have posted it here.
I use struts 2 and have the following code in the action class
And the jsp page has the following call
The issues looks like the property tag is processes the data. Is there a way to prevent the property tag from doing this.
|
 |
Sagar Rohankar
Ranch Hand
Joined: Feb 19, 2008
Posts: 2896
|
|
Don't know whether this will works for you, but give it a try,
Just escape the single quote " ' ", while creating JSON object like,
|
[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
|
 |
Jay Abrahm
Ranch Hand
Joined: May 28, 2008
Posts: 182
|
|
Thanks Sagar.
Thats the problem. I would have escaped it in the struts code but unfortunately I am using a JSONObject.
Is there a way to escape it in the property tag ?
|
 |
Sagar Rohankar
Ranch Hand
Joined: Feb 19, 2008
Posts: 2896
|
|
Jay Abrahm wrote:I would have escaped it in the struts code but unfortunately I am using a JSONObject.
Hmm, I thought that JSONObject class is developed by you as a helper class.
Maybe, we can repleace that JSON string with "\'", like
Jay Abrahm wrote:
Is there a way to escape it in the property tag ?
Never used Struts 2, but while exploring it <s:property> tag, I found something useful, its "escape" attribute itself, but its default value is "true", so don't think will it make any difference or not !!
Still use it and make its default value as a "false"
|
 |
Jay Abrahm
Ranch Hand
Joined: May 28, 2008
Posts: 182
|
|
Issue resolved. Thanks and that was quick. I didn't notice your post coming in.
Yes, escape="false" did fix the escape for double quotes issue.
I still have another issue with the dojo not accepting the JSON (commented in the alerts above) but I guess the moderator might hack me down if I try to use this forum for that
|
 |
Jay Abrahm
Ranch Hand
Joined: May 28, 2008
Posts: 182
|
|
Just a side note. Even the JSON to dojo is working now fine. The nested object should also be a JSONObject.
I beginning to like JSON !!
|
 |
 |
|
|
subject: Struts and JSON
|
|
|