title: LitJSON: Unable to use foreach in Unity
body: <p>I'm using <a href="http://lbv.github.io/litjson/" rel="nofollow">LitJSON</a> to load .json data, and I'm running some test code with a foreach loop, but it's not working.</p>
  
  <pre><code>InvalidOperationException: Instance of JsonData is not a dictionary
  LitJson.JsonData.EnsureDictionary()
  </code></pre>
  
  <p>(this error is thrown when the foreach line is run)</p>
  
  <pre><code>    using UnityEngine;
      using LitJson;
      using System.Collections;
      using System.Collections.Generic;
      using System.IO;
  
      public void LoadData() {
          JsonReader reader = new JsonReader("[1, 2, 3, 4, 5]");
          JsonData data = JsonMapper.ToObject(reader);
  
          foreach (JsonData i in data) {
            Debug.Log("foreach: test");
          }
      }
  </code></pre>
  
  <p>According to the <a href="https://lbv.github.io/litjson/docs/quickstart.html" rel="nofollow">example in the documentation</a> (Ctrl+F "foreach"; it's near the bottom of the page), I'm pretty sure this code should work (?).</p>
  
  <p>Anyone have any ideas as to why this wouldn't work? Advice would be greatly appreciated! </p>
  
  <p><strong>Edit:</strong> The solution is to cast data to an IList object as follows:</p>
  
  <pre><code>foreach (JsonData i in data as IList) {
      Debug.Log("foreach: " + i)
  }
  </code></pre>