title: Dynamically Select Required JSON information
body: <p>I need to deserialize some JSON but the problem is that all of my JSON objects don't have the exact same format.
  Here is an example of the JSON that I have to deserialize :</p>
  
  <pre><code>[
    {
      "Player_Name": "Zlatan Ibrahimovic",
      "Country": "Sweeden",
      "Other_Informations": {
        "Information1": [
  
        ]
      },
    },
     {
      "Player_Name": "Pavel Nedved",
      "Country": "Czech Republic",
      "Personal_Honours": 
          {
              "Ballon_DOr": "One",
          },
      "Other_Informations": {
        "Information1": [
  
        ]
      },
    },
     {
      "Player_Name": "Zinedine Zidane",
      "Country": "Sweeden",
      "Other_Informations": {
        "Information1": [
          {
            "name": "example",
          }
        ]
      },
    }
   ]
  </code></pre>
  
  <p>As you can see, some fields appear only for some objects for example "Personal_Honours". 
  I need to deserialize the JSON into this class :   </p>
  
  <pre><code>public class PlayerData
  {
      public string Name { get; set; }
      public string BallonDor {get; set; }
      public string Information1{ get; set; }
      public string Country{ get; set; }
  }
  </code></pre>
  
  <p>I use this method which is really long and blocks my app : 
  (In this exmple I use Json that comes frome a textfile but usually  I have to make a REST request..)</p>
  
  <pre><code>StreamReader reader = File.OpenText("TextFile1.txt");
  List&lt;PlayerData&gt; DataList;
  dynamic value= JsonConvert
      .DeserializeObject&lt;dynamic&gt;(reader.ReadToEnd());
  
  
  DataList = new List&lt;PlayerData&gt;();
      foreach (dynamic data in value)
                      {
  
                          if (data.Personal_Honours == null)
                          {
                              if (data.Other_Informations.Information1 == null)
                              {
                                  DataList.Add(new PlayerData
                                  {
                                      Name = data.Player_Name,
                                      Country = data.Country,
                                  });
                              }
                              else                            
                              {
                                  DataList.Add(new PlayerData
                                  {
                                      Name = data.Player_Name,
                                      Country = data.Country,
                                      Information1 = data.Informations.Information1
                                  });
  
                              }
  
                          }
                          else 
                          {
                              if (data.Other_Informations.Information1 == null)
                              {
  
                                  DataList.Add(new PlayerData
                                  {
                                      Name = data.Player_Name,
                                      Country = data.Country,
                                      BallonDor = data.Personal_Honours.Ballon_DOr
  
                                  });
                              }
                              else 
                              {
                                  DataList.Add(new PlayerData
                                  {
                                      Name = data.Player_Name,
                                      Country = data.Country,
                                      BallonDor = data.Personal_Honours.Ballon_DOr,
                                      Information1 = data.Informations.Information1
  
                                  });
  
                              }
  
                          }
  
                      }
  </code></pre>
  
  <p>This method is working but it is not efficient and  blocks my UI. 
  How can I do to create a  new "PlayerData"  object without having all of those   'else if'  statements ?<br>
  Thank you !</p>
  
  <p>P.S : The question is different from this one <a href="https://stackoverflow.com/questions/24333729/filter-json-information">Filter JSon Information</a> </p>
  
  <p>EDIT : </p>
  
  <p>Here is how I got the RunTimeBinderExcepetion :</p>
  
  <pre><code> List&lt;PlayerData&gt; datalist = new List&lt;PlayerData&gt;();
  
      foreach (dynamic pl in timeline)
      {
  
  
  
          datalist.Add(new PlayerData 
          { 
  
           Name  = pl.Player_Name , 
           Country = pl.Country ,
            BallonDor = pl.Personal_Honours.Ballon_Dor,
             Information1 = pl.Other_Informations.Information1.name
  
          });
      }
  </code></pre>