title: Serialize and Deserialize Json and Json Array in Unity
body: <p>I have a list of items send from a PHP file to unity using <code>WWW</code>.</p>
  
  <p>The <code>WWW.text</code> looks like:</p>
  
  <pre><code>[
      {
          "playerId": "1",
          "playerLoc": "Powai"
      },
      {
          "playerId": "2",
          "playerLoc": "Andheri"
      },
      {
          "playerId": "3",
          "playerLoc": "Churchgate"
      }
  ]
  </code></pre>
  
  <p>Where I trim the extra <code>[]</code> from the <code>string</code>. When I try to parse it using <code>Boomlagoon.JSON</code>, only the first object is retrieved. I found out that I have to <code>deserialize()</code> the list and have imported MiniJSON. </p>
  
  <p>But I am confused how to <code>deserialize()</code> this list. I want to loop through every JSON object and retrieve data. How can I do this in Unity using C#?</p>
  
  <p>The class I am using is </p>
  
  <pre><code>public class player
  {
      public string playerId { get; set; }
      public string playerLoc { get; set; }
      public string playerNick { get; set; }
  }
  </code></pre>
  
  <p>After trimming the <code>[]</code> I am able to parse the json using MiniJSON. But it is returning only the first <code>KeyValuePair</code>. </p>
  
  <pre><code>IDictionary&lt;string, object&gt; players = Json.Deserialize(serviceData) as IDictionary&lt;string, object&gt;;
  
  foreach (KeyValuePair&lt;string, object&gt; kvp in players)
  {
      Debug.Log(string.Format("Key = {0}, Value = {1}", kvp.Key, kvp.Value));
  }
  </code></pre>
  
  <p>Thanks!</p>