title: Deserialization of JSON object with List<> using DataContractJsonSerializer in C#
body: <p>I want to deserialize a JSON object that contains a single member; a string array:</p>
  
  <pre><code>{"errores":[{"errorCode":"campo1","errorMessage":"Errorenelcampo1"},{"errorCode":"campo2","errorMessage":"Errorenelcampo2"},{"errorCode":"campo3","errorMessage":"Errorenelcampo3"},{"errorCode":"campo4","errorMessage":"Errorenelcampo4"}]}"
  </code></pre>
  
  <p>This is the class that I'm trying to deserialize into:</p>
  
  <pre><code>[DataContract]
  internal class rptaNo
  {
      [DataMember]
      public List&lt;Errors&gt; errores { get; set; }
  
      [DataContract]
      protected internal struct Errors
      {
          [DataMember]
          public string codigo { get; set; }
          [DataMember]
          public string descripcion { get; set; }
      }
  }
  </code></pre>
  
  <p>This is the method that I try to deserialize:</p>
  
  <pre><code>public T Deserialise&lt;T&gt;(string json)
  {
      DataContractJsonSerializer deserializer = new DataContractJsonSerializer(typeof(T));
      using (MemoryStream stream = new MemoryStream(Encoding.Unicode.GetBytes(json)))
      {
          T result = (T)deserializer.ReadObject(stream);
          return result;
      }
  }
  </code></pre>
  
  <p>But when I check, all fields of the sub list are blank, for example</p>
  
  <pre><code>MessageBox.Show(deserializedRpta2.errores[0].descripcion);
  </code></pre>
  
  <p>I guess there must be something I'm missing = (</p>