title: Parsing JSON string to .NET Object
body: <p>I´m parsing a JSON string to a corresponding .NET Object with the Newtonsoft library. I have a problem parsing JSON properties that are arrays. Sometimes the JSON property is an array, other times, it is a single element.</p>
  
  <p>Example:</p>
  
  <p>This is the .NET object:</p>
  
  <pre><code>  public class xx
    {
        public string yy { get; set; }       
        public List&lt;string&gt; mm{ get; set; }        
    }
  </code></pre>
  
  <p>When i receive this JSON:</p>
  
  <pre><code>{ "xx": {"yy":"nn", "mm": [ "zzz", "aaa" ] } }
  </code></pre>
  
  <p>I perfectly can do:</p>
  
  <pre><code>JsonConvert.DeserializeObject&lt;xx&gt;(json);
  </code></pre>
  
  <p>But sometimes I receive this JSON:</p>
  
  <pre><code>{ "xx": {"yy":"nn", "mm":"zzz"} }
  </code></pre>
  
  <p>And the deserialization fails because of the list property on the C# object.</p>
  
  <p>How can I define an object for deserialize the two JSON string in the same object (with <code>List&lt;string&gt;</code>).</p>
  
  <p>-------- UPDATE -----</p>
  
  <p>First of all a WS generate a XML doing some operation.. the XML is like</p>
  
  <pre><code>&lt;xx yy='nn'&gt;&lt;mm&gt;zzz&lt;/mm&gt;&lt;/xx&gt;
  </code></pre>
  
  <p>and if there are more elements is:</p>
  
  <pre><code>&lt;xx yy='nn'&gt;&lt;mm&gt;zzz&lt;/mm&gt;&lt;mm&gt;aaa&lt;/mm&gt;&lt;/xx&gt;
  </code></pre>
  
  <p>finally the WS convert this XML doing:</p>
  
  <pre><code>XmlDocument doc = new XmlDocument();
  doc.LoadXml(xml);           
  var json = JsonConvert.SerializeXmlNode(doc); 
  </code></pre>
  
  <p>and send to me the json.. and here begins my problem.. </p>