Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Struts and JSON

 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't know whether this will works for you, but give it a try,
Just escape the single quote " ' ", while creating JSON object like,

 
Jay Abrahm
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 !!

 
Everybody! Do the Funky Monkey! Like this tiny ad!
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!