I’m using Gson to convert a Java object to Json. One of the object’s fields holds a string containing an escaped double quote, like this:
"double quote:'\"'"
The toJson method returns the string as above, but I would like to print this instead:
double quote:'"'
Is this possible using Gson?
Why would you want to do that? The surrounding quotes and the escape character are mandatory in JS/JSON as well.
The following JS piece just shows the correct value:
Don’t print it using
System.out.println()or so, Java doesn’t parse JSON, only JS does that 😉