title: Deserialize array Object using Newtonsoft Json.Net
body: <p>I have following json string</p>
  
  <pre><code>[
      {
          "itemtype": "note",
          "body": "some text"
      },
      {
          "itemtype": "list",
          "items": [
              {
                  "item": "some text"
              },
              {
                  "item": "some text"
              }
          ]
      },
      {
          "itemtype": "link",
          "url": "some link"
      }
  ]
  </code></pre>
  
  <p>Which I need to parse in C#. My string might return error codes like this (or any other unknown error codes)</p>
  
  <pre><code>{"Error":"You need to login before accessing data"}
  </code></pre>
  
  <p>Or it might be just an empty array (no data)</p>
  
  <pre><code>[]
  </code></pre>
  
  <p>Here is my code</p>
  
  <pre><code>public void ParseData(string inStr) {
      if (inStr.Trim() != "") {
          dynamic result = JsonConvert.DeserializeObject(inStr);
          if (result is Array) {
              foreach (JObject obj in result.objectList) {
                  switch (obj.Property("itemtype").ToString()) {
                      case "list": // do something
                          break;
                      case "note": // do something
                          break;
                      case "link": // do something
                          break;
                  }
              }
          } else {
              // ... read error messages
          }
      }
  }
  </code></pre>
  
  <p><strong>Problem</strong></p>
  
  <p>In above code <code>result</code> is never of type <code>Array</code>. in fact I have no way to check what is its type either (I tried typeof).</p>
  
  <p><strong>Question</strong></p>
  
  <p>How can I check if I have an array in string and how can I check if it has objects in it (Please note, this is not a typed array)</p>