title: How to convert JsonNode to String without escaping quote - with \" instead of "
body: <p>I have the following class. I use <code>ObjectMapper.convertValue()</code> to convert this class to Jackson ObjectNode. Then <code>ObjectNode.toString()</code> will return a String like <code>"{"playing": false}"</code>. </p>
  
  <p>But what I am looking for is the Json String without escaping quote like <code>"{\"playing\": false}"</code>. </p>
  
  <p>I am currently using <code>String.replace("\"", "\\\"")</code>, and it worked. Is there any better way to achieve that?</p>
  
  <p><strong>Update Node:</strong> As mentioned in the comment, I need to send this state String to server, but it looks like my server can only recognize <code>"{\"playing\": false}"</code>.</p>
  
  <pre><code>public class MyState {
      public Boolean playing;
  }
  
  private String getStateString()
  throws Exception
  {
      ObjectNode objectNode = objectMapper.convertValue(currentState, ObjectNode.class);
      String pretty = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(objectNode);
      return objectNode.toString().replace("\"", "\\\"");
  }
  </code></pre>
  
  <p><strong>Update Solution:</strong> As mentioned in comment, the root cause that the service was not able to process my state string is not due to string escape, but due to incorrect attribute name (which is further converted to json key String).</p>