use of org.openmrs.OpenmrsCharacterEscapes in project openmrs-core by openmrs.
the class StartupFilter method toJSONString.
/**
* Convenience method to convert the given object to a JSON string. Supports Maps, Lists,
* Strings, Boolean, Double
*
* @param object object to convert to json
* @return JSON string to be eval'd in javascript
*/
protected String toJSONString(Object object) {
ObjectMapper mapper = new ObjectMapper();
mapper.getJsonFactory().setCharacterEscapes(new OpenmrsCharacterEscapes());
try {
return mapper.writeValueAsString(object);
} catch (IOException e) {
log.error("Failed to convert object to JSON");
throw new APIException(e);
}
}
Aggregations