title: How to keep order of values while adding them to JSONArray?
body: <p>I need to generate a JSON from a list of objects. To do it I am using the following code, but I have two problems:</p>
  
  <ol>
  <li>The order of entries get changes</li>
  <li>It adds <code>\</code> before all <code>"</code> when I show the JSON.</li>
  </ol>
  
  <p></p>
  
  <pre><code>JSONObject jsonObj = new JSONObject();
  for (Row row : rows) {
      jsonObj.put(row.getCode(),row.getValue());
  
  }
  myJson.put(jsonObj.toString());
  System.err.println("myJson:" + myJson.toString());
  </code></pre>
  
  <p><strong>Output</strong></p>
  
  <pre><code>myJson:["{\"1234445\":\"Jack"}"]
  </code></pre>
  
  <p>Thanks to  Sotirios Delimanolis , after removing .toString() from jsonObj the first problem has been solved.</p>