title: Convert nested java objects to Jackson JSON
body: <p>Could someone provide an example or reference that provides a way to convert a nest JAVA object to JSON output using Jackson libraries preferably. I have no problem converting a flat JAVA object. However the JSON libraries show the nested object name and type rather than its sub-objects.  I'm pretty much leveraging the same code provided here <a href="http://www.mkyong.com/java/jackson-2-convert-java-object-to-from-json/" rel="nofollow noreferrer">http://www.mkyong.com/java/jackson-2-convert-java-object-to-from-json/</a> . So I'm not attaching any code example.</p>
  
  <p>e.g.</p>
  
  <p><strong>This is what I get:</strong></p>
  
  <pre><code>{
    "fname": null,
    "lname": null,
    "addr": null
  }
  </code></pre>
  
  <p><strong>This is what I need as output:</strong></p>
  
  <pre><code>{
      "name":null,
      "lname":null,
      "addr":{
          street:"mull",
          "city":null,
          "zip":0
      }
  }
  </code></pre>
  
  <p><strong>This the sample class objects:</strong></p>
  
  <pre><code>import address;
  
  public class id implements Serializable {
  public String fname;
  public String lname;
  public address addr; 
  
  } 
  
  public class address implements Serializable {
  public String street;
  public String city; 
  public int zip;
  }
  </code></pre>