I am trying to build json string from my java object. This object contains string with '&' and '='. Now after calling gson.toJson my string changes from those charecters to \u003d and \u0026.
Example:
public static void main(String[] args) {
MyObj myObj = new MyObj();
myObj.setUrl("www.koko.com?k=1&v=2");
Gson g = new Gson();
System.out.println(g.toJson(myObj));
}
public static class MyObj{
private String url;
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
}
OUTPUT:
{"url":"www.koko.com?k\u003d1\u0026v\u003d2"}
Expecting:
{"url":"www.koko.com?k=1&v=2"}
Any suggestions how to avoid this behavior ?
Thanks