title: Convert XML to Json Array when only one object Java
body: <p>I have one XML which i need to convert to JSON when in XML we have more than one element its creating proper jsonArray but when single element not creating the array can any one please help me how we can get array in case of single element</p>
  
  <pre><code>String TEST_XML_STRING = "&lt;Items&gt;&lt;Item&gt;&lt;Name&gt;Stack&lt;/Name&gt;&lt;Name&gt;OverFlow&lt;/Name&gt;&lt;/Item&gt;&lt;/Items&gt;";
  JSONObject xmlJSONObj = XML.toJSONObject(TEST_XML_STRING);
  // output - {"Items":{"Item":{"Name":["Stack","OverFlow"]}}}
  </code></pre>
  
  <p>when </p>
  
  <pre><code>String TEST_XML_STRING = "&lt;Items&gt;&lt;Item&gt;&lt;Name&gt;Stack&lt;/Name&gt;&lt;/Item&gt;&lt;/Items&gt;";
  JSONObject xmlJSONObj = XML.toJSONObject(TEST_XML_STRING);
  // output - {"Items":{"Item":{"Name":"Stack"}}}
  </code></pre>
  
  <p>but it should be <code>{"Items":{"Item":[{"Name":"Stack"}]}}</code></p>