Hello i'm trying to convert my Java Object to a Json string to use in my view with javascript functions.
I tried to use Google's gson lib:
String myjson = "";
Gson gson = new Gson();
myjson = gson.toJson(myuser);//myuser is my java object
However when i call myjson, it consists of '"
' instead of the character '"
' for this reason i can't able to use it in my view, it is creating me problems.
How can I fix this, how can I create Json string properly?
Edit : Is there a chance of making a mistake while rendering the myjson?
Edit2: To reach the result of myjson in view, i'm doing
render(myjson);
at the end of my code.
Edit3: Play framework has a method of renderJSON(). However i can't use it since i'm rendering not only myjson and some other elements too.