I want to include html in my JSON response.
MyClass obj= new MyCLass();
obj.setHTML("<div style='display:none'>4</div>");
ObjectMapper mapper=new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
String jsonResponse=mapper.writeValueAsString(obj);
System.out.println(jsonResponse);
O/P i get
{"html":"<div style=\"display:none\">4</div>"}
Required O/P
{"html":"<div style='display:none'>4</div>"}
Since I want to use the json response directly. Can i disable the escaping of qoutes by object mapper.
You can annotate your getHtml method with
@JsonRawValue
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With