This week's book / license giveaways are in the JDBC and Relational Databases and Java in General forums.
We're giving away four copies each of PostGIS in Action and Java Advanced Topics Training and have the authors on-line!
See this thread and this one for details.
The moose likes HTML, CSS and JavaScript and the fly likes Passing Json in a String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Passing Json in a String" Watch "Passing Json in a String" New topic
Author

Passing Json in a String

Tarun Oohri
Ranch Hand

Joined: Feb 20, 2013
Posts: 186
Hi Everyone,
I am trying to use jQuery with servlet to generate dynamic table in the view page. I am using jquery.dataTables.js & jquery.js to generate dynamic table.
In the above String json i am giving fixed data to be shown in the table. But what i want is to get the data from database and pass them here on Runtime. eg: if i want to pass "jhon" instead of "awesome" , how would i "s" reference to it .

Thanks in Advance !!
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31798
    
192

Tarun,
If you can guarantee that the String doesn't have special characters like quotes in it, you can just append it:




If you don't know this, I recommend using a library like Gson to protect you from those characters. Or have a regular expression to strip them out before appending.


[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Tarun Oohri
Ranch Hand

Joined: Feb 20, 2013
Posts: 186

Thanks a lot Jeanne its working now , just appended it as you showed . Thanks Again!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing Json in a String