title: How to Create Complex JSON out of Java libraries. GSON/JACKSON
body: <p>I am working on an API which needs JSON objects from instantiation of classes. I am looking into [GSON library][1] with java. And seems like it can serve me well as I need to have JSON based on classes(see below). An instance of those classes generate JSON output and should look like this:</p>
  <pre><code> {
    &quot;Command&quot;: &quot;login&quot;,
    &quot;uid&quot;: &quot;123123123&quot;,
    &quot;params&quot;: {
      &quot;username&quot;: &quot;dev_2454&quot;,
      &quot;password&quot;: &quot;4546845446&quot;
    }
  }
  </code></pre>
  <p>And the java classes are as follows.</p>
  <pre><code>public class LoginInfo {
      private String Command;
      private String uid;
      private Params params;
  }
  
  public class Params {
      private String username;
      private String password;
  }
  </code></pre>
  <p>I am not sure how to begin. Any help is welcomed. Any other library example is also appreciated. Thanks.
  [1]: <a href="https://code.google.com/p/google-gson/" rel="nofollow noreferrer">https://code.google.com/p/google-gson/</a></p>