I try to do in a Servlet:
JSONObject json = new JSONObject();
json.put( "eventContent", "event" );
String script = "var object= " + json.toJSONString() + ";";
response.getWriter().print( something + script + another );
The content of script is of course:
var object = {"eventContent":"event"};
But I render this String into a javascript function and try to refer a existent javascript object “event”. So I need the value in the JSON Sting without quotes.
var object = {"eventContent":event};
any suggestions? 🙂
thanks a lot
I think it’s not really JSON, since you should not refer variables. Anyway you can obtain what you need by implementing the
JSONStringinterface, like this.