title: How to make a nested Json object in Java?
body: <p>I want to program a nested JSON Object for my Android device, but how? I have only basic experience with Json, so I would appreciate if someone could help me with the following code:</p>
  
  <pre><code>{ 
   "command": "login",
   "uid": "123123123",
   "params":
    {
     "username": "sup",
     "password": "bros"
    }
  }
  </code></pre>
  
  <p>Edit:</p>
  
  <p>The following code does solve the problem:</p>
  
  <pre><code>loginInformation = new ArrayList&lt;NameValuePair&gt;(); 
  
  JSONObject parentData = new JSONObject();
  JSONObject childData = new JSONObject();
  
  try {
  
      parentData.put("command", "login");
      parentData.put("uid", UID.getDeviceId());
  
      childData.put("username", username.getText().toString());
      childData.put("password", password.getText().toString());
      parentData.put("params", childData);
  
  } catch (JSONException e) {
      e.printStackTrace();
  }
  
  loginInformation.add(new BasicNameValuePair("content", parentData.toString()));
  </code></pre>