title: JSON - Unable to serialize JSONObject within Object using Jackson
body: <p>I have the following class:</p>
  
  <pre><code>class A{    
      String abc;
      String def;
      // appropriate getters and setters with JsonProperty Annotation 
  }
  </code></pre>
  
  <p>and I call <code>Jacksons objectMapper.writeValueAsString(A)</code> which works fine.</p>
  
  <p>Now I need to add another instance member:</p>
  
  <pre><code>class A{    
      String abc;
      String def;
      JSONObject newMember; // No, I cannot Stringify it, it needs to be JSONObject
      // appropriate getters and setters with JsonProperty Annotation 
  }
  </code></pre>
  
  <p>but when I serialize, I am getting exception:</p>
  
  <pre><code>org.codehaus.jackson.map.JsonMappingException: No serializer found for class org.json.JSONObject and no properties discovered to create BeanSerializer
  </code></pre>
  
  <p>I tried JSONNode but it gave Output as {outerjson:<strong>"</strong>{innerjson}<strong>"</strong>} not {outerjson:{innerjson}}.</p>
  
  <p>Is it possible to use Jackson to achieve the above output, i.e. JSONObject within JSONObject?</p>
  
  <p><img src="https://i.stack.imgur.com/31hdG.png" alt="enter image description here"></p>