title: Convert XML to Json Array when only one object
body: <p>I am currently using Newtonsoft to convert some xml to json to return from a RestExtension.</p>
  
  <p>My xml is in the form of </p>
  
  <pre><code>&lt;Items&gt;
    &lt;Item&gt;
      &lt;Name&gt;name&lt;/Name&gt;
      &lt;Detail&gt;detail&lt;/Detail&gt;    
    &lt;/Item&gt;
    &lt;Item&gt;
      &lt;Name&gt;name&lt;/Name&gt;
      &lt;Detail&gt;detail&lt;/Detail&gt;    
    &lt;/Item&gt;
  &lt;/Items&gt;
  </code></pre>
  
  <p>I convert this to json using </p>
  
  <pre><code>JsonConvert.SerializeXmlNode(xmldocument);
  </code></pre>
  
  <p>This works fine if there is more than one item. </p>
  
  <p>I get this - an array of items in json (which is what I need):</p>
  
  <pre><code>{"Items":{"Item":[{"Name":"name","Detail":"detail"},{"Name":"name","Detail":"detail"}]}}
  </code></pre>
  
  <p>But when there is only one it quite understandably converts like this (not an array):</p>
  
  <pre><code> {"Items":{"Item":{"Name":"name","Detail":"detail"}}}
  </code></pre>
  
  <p>My app developer who is reading this needs the json to return an array of items regardless or whether there is one or more.</p>
  
  <p>Is there a way of tricking it into thinking it's an array or can someone suggest another way of doing this?</p>