title: How to avoid Jackson escaping double quotes in Java?
body: <p>I am working on a project and wanted to rewrite some code written in Gson to Jackson using ObjectMapper. So I am trying to create a JSON string using some properties as below:</p>
  <pre class="lang-java prettyprint-override"><code>ObjectMapper objectMapper = new ObjectMapper();
  ObjectNode objNode= objectMapper.createObjectNode();
  objNode.put(&quot;identifierVal&quot;, UUID.randomUUID().toString());
  objNode.put(&quot;version&quot;, &quot;two&quot;);
  List&lt;String&gt; namesList= new ArrayList&lt;&gt;();
  namesList.add(&quot;test&quot;);
  objNode.put(&quot;namesList&quot;, namesList.toString());
  String requestObject = objectMapper.writeValueAsString(objNode.toString());
  </code></pre>
  <p><strong>Expected result:</strong></p>
  <pre class="lang-json prettyprint-override"><code>{
     &quot;identifierVal&quot;:1234,
     &quot;version&quot;:&quot;two&quot;,
     &quot;namesList&quot;:[
        &quot;test&quot;
     ]
  }
  </code></pre>
  <p><strong>Actual:</strong></p>
  <pre class="lang-json prettyprint-override"><code>&quot;{  
          &quot;\identifierVal\&quot;: 1234,   
          &quot;\version\&quot;:&quot;\two\&quot;,
  &quot;\namesList\&quot;: [&quot;\test\&quot;]
  
      }&quot;
  </code></pre>
  <p>So once I create a JSON String using Jackson, it turns out it is escaping double quotes for field names and values and adding a <code>\</code> at leading and trailing spaces. So service call fails due to the escaping.</p>
  <p>I have went through some documentation and I can understand Jackson is escaping double quotes. But is there a way to avoid escaping double quotes and adding of leading and trailing double quotes.</p>
  <p>Any help is appreciated. BTW, I followed the links below:</p>
  <p><a href="https://stackoverflow.com/questions/52394853/why-objectnode-adds-backslash-in-in-json-string">Why ObjectNode adds backslash in in Json String</a></p>
  <p><a href="https://stackoverflow.com/questions/41815818/jackson-adds-backslash-in-json/41816988">Jackson adds backslash in json</a></p>