title: How to convert a Java Object to a JSONObject?
body: <p>i need to convert a POJO to a JSONObject (org.json.JSONObject)</p>
  
  <p>I know how to convert it to a file:</p>
  
  <pre><code>    ObjectMapper mapper = new ObjectMapper();
      try {
          mapper.writeValue(new File(file.toString()), registrationData);
      } catch (JsonGenerationException e) {
          e.printStackTrace();
      } catch (JsonMappingException e) {
          e.printStackTrace();
      } catch (IOException e) {
          e.printStackTrace();
      }
  </code></pre>
  
  <p>But I dont want a file this time.</p>