title: how to deserialize part of the JSON object using JSON.NET
body: <p>I am working on an asp.net mvc web application. and i am receiving the following json object :-</p>
  
  <pre><code>{  
     "operation":{  
        "name":"GET RESOURCE ACCOUNTLIST",
        "result":{  
           "status":"Success",
           "message":"Resource details with account list fetched successfully"
        },
        "Details":{  
           "RESOURCE ID":"1",
           "RESOURCE NAME":"test resource",
           "RESOURCE DESCRIPTION":"",
           "RESOURCE TYPE":"Windows",
           "DNS NAME":"172.16.20.101",
           "PASSWORD POLICY":"Strong",
           "DEPARTMENT":"",
           "LOCATION":"",
           "RESOURCE URL":"",
           "RESOURCE OWNER":"admin",
           "ACCOUNT LIST":[  
              {  
                 "ISFAVPASS":"false",
                 "ACCOUNT NAME":"root",
                 "PASSWDID":"1",
                 "IS_TICKETID_REQD_MANDATORY":"false",
                 "ISREASONREQUIRED":"false",
                 "AUTOLOGONLIST":[  
                    "Windows Remote Desktop",
                    "Remote Desktop"
                 ],
                 "PASSWORD STATUS":"****",
                 "IS_TICKETID_REQD":"false",
                 "ACCOUNT ID":"1",
                 "AUTOLOGONSTATUS":"User is not allowed to automatically logging in to remote systems in mobile",
                 "IS_TICKETID_REQD_ACW":"false"
              }
           ]
        }
     }
  }
  </code></pre>
  
  <p>I am using JSON.NET to do the deserilization, so I created the following  model classes (I did not include all the properties received by the JSON object since I do not really need all of them).</p>
  
  <pre><code>public class ResourceAccountListInfo
  {
      public Operation2 operation { get; set; }
  }
  
  public class Operation2
  {    
      public string name { get; set; }
      public Result result { get; set; }
      public IList&lt;Details2&gt; Details { get; set; }    
  }
  
  public class Details2
  {     
      [JsonProperty("RESOURCE DESCRIPTION")]
      public string RESOURCEDESCRIPTION { get; set; }
  
      [JsonProperty("RESOURCE NAME")]
      public string RESOURCENAME { get; set; }
  
      [JsonProperty("RESOURCE ID")]
      public string RESOURCEID { get; set; }
  
      [JsonProperty("RESOURCE TYPE")]
      public string RESOURCETYPE { get; set; }
  
      [JsonProperty("DNS NAME")]
      public string DNSNAME { get; set; }
  
      [JsonProperty("ACCOUNT LIST")]
      public IList&lt;ACCOUNTLIST&gt; ACCOUNTLIST { get; set; }
  }
  </code></pre>
  
  <p>I am getting the following error when I try to deserialize json using this statement:</p>
  
  <pre><code>  ResourceAccountListInfo resourceAccountListInfo = JsonConvert.DeserializeObject&lt;ResourceAccountListInfo&gt;(json); 
  </code></pre>
  
  <p>Error is :</p>
  
  <pre><code>Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.IList`1[T.ViewModels.Details2]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
  To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List&lt;T&gt;) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.
  Path 'operation.Details.['RESOURCE ID']', line 1, position 171
  </code></pre>
  
  <p>I think the problem is that there are some properties inside my JSON object which do not have a mapping inside the model classes, could this be a reason?</p>