title: Inverted order of JSON elements in Java after XML conversion
body: <p>I'm using the <a href="http://www.json.org/java/" rel="noreferrer">JSON in Java</a> for the transformation of XML to JSON. I have the problem that this implementation is inverting all child elements.</p>
  
  <p>When I pass this XML:</p>
  
  <pre><code>&lt;Person&gt;&lt;Child1&gt;a&lt;/Child1&gt;&lt;Child2&gt;b&lt;/Child2&gt;&lt;/Person&gt;
  </code></pre>
  
  <p>I will end up with a JSON having the childs inverted:</p>
  
  <pre><code>{"Person":{"Child2":"b", "Child1":"a"}}
  </code></pre>
  
  <p>My Java code:</p>
  
  <pre><code>JSONObject jsonObject= XML.toJSONObject("&lt;Person&gt;&lt;Child1&gt;a&lt;/Child1&gt;&lt;Child2&gt;b&lt;/Child2&gt;&lt;/Person&gt;");
  String myJSONString = jsonObject.toString(4);
  </code></pre>
  
  <p>How to transform to JSON with keeping the order of the elements (like in XML)? </p>