title: Json Deserialization is not working with Flurl
body: <p>I try to consume an json APIwith Flurl from a website and I'm getting parse errors or conversion errors. I'm not sure what is my problem since is the first time I deal with json files. I utilize the following online <a href="https://www.site24x7.com/tools/json-to-csharp.html" rel="nofollow noreferrer">tool</a> to create a C# object out of the json file. But when I try to get a response with Flurl I get the following errors.</p>
  
  <blockquote>
    <p><em>System.AggregateException: One or more errors occurred. ---> Flurl.Http.FlurlParsingException: Response could not be deserialized
    to JSON: GET  --->
    Newtonsoft.Json.JsonSerializationException:  Error converting value
    "{"Group":[{"name":"Senior","id":1},{"name":"Age","id":1}],"Area":[{"AreaID":58,"Description":"Years
    2018-19","Week":1150,"taken":true,"LDate":null","Label":"RED"}]</em></p>
    
    <p><em>Path '', line 1, position 4814377. ---> System.ArgumentException: Could not cast or convert from System.String to
    System.Collections.Generic.List`1[JsonTest.SeatTest].</em></p>
  </blockquote>
  
  <p>This is the chunk of code that fails:</p>
  
  <pre><code>var response = await url.WithHeaders(new
      User_Agent = ConstantData.UserAgent,
      Accept = Accept,
      Referer = Referer})
      ..GetJsonAsync&lt;List&lt;SeatTest&gt;&gt;()
      .Result;
  </code></pre>
  
  <p>But now if I use the following:</p>
  
  <pre><code>var response = await url.WithHeaders(new
      User_Agent = ConstantData.UserAgent,
      Accept = Accept,
      Referer = Referer})
      .GetStringAsync()
      .Result;
  </code></pre>
  
  <p>I get (which I think is normal, not sure) the following string when I do a quick watch or hover over the response variable.</p>
  
  <blockquote>
    <p>"\"{\\"Group\\":[{\\"name\\":\\"Senior\\",\\"id\\":1},{\\"name\\":\\"Age\\",\\"id\\":1}],\\"Area\\":[{\\"AreaID\\":58,\\"Description\\":\\"Years
    2018-19\\",\\"Week\\":1150,\\"taken\\":true,\\"LDate\\":null",\\"Label\\":\\"RED\\"}]</p>
  </blockquote>
  
  <p>If I apply the following: </p>
  
  <pre><code>var json = JsonConvert.DeserializeObject&lt;SeatTest&gt;(response);
  </code></pre>
  
  <p>it will also throw the exception that I already post.</p>
  
  <h2>OR</h2>
  
  <p>If I skip the above line and do the following:</p>
  
  <pre><code>var jSerial = new JavaScriptSerializer();
  jSerial.MaxJsonLength = 50000000;
  string jsonStr = jSerial.Deserialize&lt;string&gt;(response); 
  var data = jSerial.Deserialize&lt;SeatTest&gt;(jsonStr);
  </code></pre>
  
  <p>My class objects appear null. But I don't get any errors or exceptions.</p>
  
  <p>The that Flurl code that I'm using looks like follow, or at least the one I want to utilize:</p>
  
  <pre><code> var response = url.WithHeaders(new
                  {
                      User_Agent = ConstantData.UserAgent,
                      Accept = Accept,
                      Referer = Referer
                  })
                      .GetJsonAsync&lt;List&lt;SeatTest&gt;&gt;()
                      .Result;
  </code></pre>
  
  <p>And my object model looks like:</p>
  
  <pre><code>public class SeatTest
      {
          [JsonProperty(PropertyName ="Group")]
          public List&lt;Group&gt; groups { get; set; }
          [JsonProperty(PropertyName = "Area")]
          public List&lt;Group&gt; areas { get; set; }
       }
  
   [Serializable]
      public class Group
      {
          public string name { get; set; }
          public int id { get; set; }
  
      }
  
   [Serializable]
   public class Area
      {
          public int AreaID{ get; set; }
          public string Description { get; set; }
          public int Week { get; set; }
          public bool Taken { get; set; }
          public DateTime LDate { get; set; }
          public string Label { get; set; }
      }
  </code></pre>
  
  <p>I expect an object that is filled with the data that comes from the API, but instead I get exceptions:</p>
  
  <blockquote>
    <p><em>System.AggregateException: One or more errors occurred. ---> Flurl.Http.FlurlParsingException: Response could not be deserialized
    to JSON: GET  --->
    Newtonsoft.Json.JsonSerializationException:  Error converting value
    "{"Group":[{"name":"Senior","id":1},{"name":"Age","id":1}],"Area":[{"AreaID":58,"Description":"Years
    2018-19","Week":1150,"taken":true,"LDate":null","Label":"RED"}]</em></p>
    
    <p><em>Path '', line 1, position 4814377. ---> System.ArgumentException: Could not cast or convert from System.String to
    System.Collections.Generic.List`1[JsonTest.SeatTest].</em></p>
  </blockquote>
  
  <h2>EDIT</h2>
  
  <pre><code>var jSerial = new JavaScriptSerializer();
  jSerial.MaxJsonLength = 50000000;
  string jsonStr = jSerial.Deserialize&lt;string&gt;(response); 
  /*First pass: Here I already got the info that I need, how I map it to my class?, since I would like to use Flurl GetAsync() and map it to my object and not a string */
  /*Above line response val:  "\{\\\"Group\\\":[{\\\"name\\\":\\\"Senior\\\",\\\"id\\\":1},{\\\"name\\\":\\\"Age\\\",\\\"id\\\":2}],\\\"Area\\\":[{\\\"AreaID\\\":58,\\\"Description\\\":\\\"Season 2018-2019\\\",\\\"Week\\\":1150,\\\"taken\\\":true,\\\"LDate\\\":\\\"2019-07-07T00:00:00\\\",\\\"Label\\\":\\\"RED\\\"}]} */
  /*Above line jsonStr val: null*/
  
  var data = jSerial.Deserialize&lt;SeatTest&gt;(jsonStr);
  /*Above line jsonStr val same as raw in postman:  "\{\"Group\":[{\"name\":\"Senior\",\"id\":1},{\"name\":\"Age\",\"id\":2}],\"Area\":[{\"AreaID\":58,\"Description\":\"Season 2018-2019\",\"Week\":1150,\"taken\":true,\"LDate\":\"2019-07-07T00:00:00\",\"Label\":\"RED\"}]} */
  /* data value after above line: Group: null, Area: null*/
  </code></pre>
  
  <h3>Raw Postman Json</h3>
  
  <pre><code>{
     \"Group\": [
          {
              \"name\": \"Senior\",
              \"id\": 1
          },
          {
              \"name\": \"Adult\",
              \"id\": 2
          }
      ],
      \"Area\": [
          {
              \"AreaID\": 58,
              \"Description\": \"Area 2018-2019\",            
              \"Week\": 1150,
              \"taken\": true,
              \"LDate\": \"2019-07-07T00:00:00\",
              \"Label\": \"RED\"
          },
          {
              \"SeasonID\": 57,
              \"Description\": \"Area 51\",           
              \"Week\": 1,
              \"taken\": true,
              \"LDate\": \"2019-07-015T00:00:00\",
              \"Label\": \"GREEN\"
          }]
  }
  </code></pre>
  
  <h3>Json also how JsonStr (first pass) looks like in Quick watch</h3>
  
  <pre><code>{
     "Group": [
          {
              "name": "Senior",
              "id": 1
          },
          {
              "name": "Adult",
              "id": 2
          }
      ],
      "Area": [
          {
              "AreaID": 58,
              "Description": "Area 2018-2019",            
              "Week": 1150,
              "taken": true,
              "LDate": "2019-07-07T00:00:00",
              "Label": "RED"
          },
          {
              "SeasonID": 57,
              "Description": "Area 51",           
              "Week": 1,
              "taken": true,
              "LDate": "2019-07-015T00:00:00",
              "Label": "GREEN"
          }]
  }
  </code></pre>