File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Passing Json in a String" Watch "Passing Json in a String" New topic

Passing Json in a String

Tarun Oohri
Ranch Hand

Joined: Feb 20, 2013
Posts: 189
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

Joined: May 26, 2003
Posts: 33132

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]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Tarun Oohri
Ranch Hand

Joined: Feb 20, 2013
Posts: 189

Thanks a lot Jeanne its working now , just appended it as you showed . Thanks Again!!!
I agree. Here's the link:
subject: Passing Json in a String
It's not a secret anymore!