title: best c# syntax/idiom, reading array of friends from Facebook
body: <p>In c#, I'm simply grabbing "/me/friends" from the FB api,</p>
  
  <pre><code>private void FacebookFriends()
      {
      FB.API("/me/friends", HttpMethod.GET, FBAPIFriendsCallback);
      }
  
  private void FBAPIFriendsCallback(FBResult response)
      {
      // (error handling here - no problem)
  
      // ugly code...
      var dict = Json.Deserialize(response.Text)
          as Dictionary&lt;string,object&gt;;
      var friendList = new List&lt;object&gt;();
      friendList = (List&lt;object&gt;)(dict["data"]);
      int _friendCount = friendList.Count;
  
      // ugly code...
      // (example shows getting one item, would loop through all)
      string id = getDataValueForKey(
            (Dictionary&lt;string,object&gt;)(friendList[0]), "id" );
      string name = getDataValueForKey(
            (Dictionary&lt;string,object&gt;)(friendList[0]), "name" );
      }
  </code></pre>
  
  <p>Notice the very, very ugly code -- what's the more elegant way to write this?  Cheers</p>
  
  <hr>
  
  <p>In fact, per swazza's comment below, here's the full code passage:</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  using System.Collections.Generic;
  using Parse;
  using System;
  using Facebook;
  using System.Threading.Tasks;
  using System.IO;
  using System.Linq;
  using Facebook.MiniJSON;
  
  
  public class ParseLinkOps : MonoBehaviour
    {
  
    ...
  
    public void GetFriendsFromFBThenMatch()
      {
      FB.API("/me/friends", HttpMethod.GET, _cbFriends);
      // FB calls at
      // https://developers.facebook.com/docs/unity/reference/current
      }
  
    private void _cbFriends(FBResult response)
      {
      // goal: given the json result from the cloud,
      // create a List&lt;string&gt; containing only the FacebookID "id" numbers
  
      if ( ! String.IsNullOrEmpty(response.Error) )
        { // .. error handling .. return; }
  
      var dict = Json.Deserialize(response.Text)
              as Dictionary&lt;string,object&gt;;
  
      var friendList = new List&lt;object&gt;();
      friendList = (List&lt;object&gt;)(dict["data"]);
  
      int _friendCount = friendList.Count;
      Debug.Log("Found friends on FB, _friendCount ... " +_friendCount);
  
      // so, convert that complex array of FB objects,
      // to simply an array of "id" strings
      // use very ugly code but assume someone on SO knows better later :-)
  
      List&lt;string&gt; friendIDsFromFB = new List&lt;string&gt;();
  
      for ( int k=0; k&lt;_friendCount; ++k)
        {
        string friendFBID =
          getDataValueForKey( (Dictionary&lt;string,object&gt;)(friendList[k]), "id");
  
        string friendName =
          getDataValueForKey( (Dictionary&lt;string,object&gt;)(friendList[k]), "name");
  
        Debug.Log( k +"/" +_friendCount +" " +friendFBID +" " +friendName);
  
        friendIDsFromFB.Add( friendFBID );
        }
  
      // we're done, the list is in friendIDsFromFB
      StartCoroutine( _match( friendIDsFromFB ) );
      }
  
    ...
    }
  </code></pre>