Log JSONObject in java without unnecessary backslashes(\)

56 views Asked by At

My code:

@Slf4j
public class MyMessage {
  public void initMy(JSONObject json) {
    log.info("Object: "+ json.toString());
  }
}

For example json={"request":"hello"} But the logs will display:

Object: {\"request\":\"hello\"} 

How to output logs without unnecessary slashes?

I try

json.toString().replace("\\\"", "\"")
0

There are 0 answers