public String toJson(Object object) {
log.debug("Converting to json " + object);
if(object instanceof String) {
return object.toString();
}
StringBufferPrinter json_buffer = new StringBufferPrinter();
Context context = Context.newInstance().put("rjson", this).and("json_buffer", json_buffer).and("cycle_set", new SoftReference<Set<?>>(new HashSet<Object>()));
object_to_json_transformer.transform(object, String.class, context);
log.debug("json before formatting is : " + json_buffer.toString());
String json = json_buffer.toString();
if(formatJson()) {
json = RjsonUtil.reformat(json_buffer.toString());
}
log.debug("json is : " + json);
return json;
}