title: How to make my JSON nicer in java ? Strictly using - org.json.JSON
body: <pre><code>import org.json.JSONArray;
  import org.json.JSONException;
  import org.json.JSONObject;
  
  import java.util.ArrayList;
  import java.util.Iterator;
  import java.util.List;
  
  public class testjson {
  
      public static void main(String args[]) throws JSONException {
          JSONObject json = new JSONObject();
          json.put("name", "timmy");
          json.put("age", "20");
  
          List&lt;String&gt; ids = new ArrayList&lt;&gt;(); 
          JSONObject jsonIds = new JSONObject();
  
          jsonIds.put("jobId", "123");
          jsonIds.put("houseId", "5");
  
  
          ids.add(jsonIds.toString(4));
  
          json.put("idList", ids);
  
          System.out.println(json.toString(4));
  
      }
  
  }
  </code></pre>
  
  <p>I want to print this out. The order of it doesn't matter but to fix the array as well. </p>
  
  <pre><code>{
      "age": "20",
      "name": "timmy",
      "idList": [
          {
              "houseId": "5", 
              "jobId": "123"
          }
      ]
  
  }
  </code></pre>
  
  <p>Currently this outputs </p>
  
  <pre><code>{
      "age": "20",
      "idList": ["{\n    \"houseId\": \"5\",\n    \"jobId\": \"123\"\n}"],
      "name": "timmy"
  }
  </code></pre>
  
  <p>as you can see the idList isn't what I want. I tried playing around with it but nothing was working. Does anyone know if this is possible with this standard json library? Or any other library that eclipse has that I wont have to separately download like jackson or gson</p>