title: How to convert string to JSON using ObjectMapper?
body: <p>I need the following JSON format using ObjectMapper using Java.</p>
  <pre><code>    ObjectMapper mapper = new ObjectMapper();
      User user = new User();
      user.set_id(1);
      int id = 2;
      user.setIndex(&quot;{\&quot;_id\&quot;:&quot; + id + &quot;}&quot;);
      mapper.writeValue(new File(&quot;user.json&quot;), user);
  </code></pre>
  <p>Output:
  {&quot;index&quot;:{&quot;_id&quot;:&quot;1&quot;}}
  {&quot;index&quot;:{&quot;_id&quot;:&quot;2&quot;}}</p>