One single reason:
Because you are not doing it correctly. You are deserializing it to a "list of list of posts". And your JSON is a "document containing posts". I could write something as simple as,
dynamic deserialize_post = JsonConvert.DeserializeObject(json);
if(deserialize_post.posts != null) {
List<Post> posts = deserialize_post.posts;
}
Now, the problem mainly is that when the data comes from an API, you either need to map it back to the "
exact" same copy of the object, or you cannot map it anywhere. You may have also seen that I used, "
posts
", instead of "
Posts
". That is because, the case also matters a lot in this case. In the case, where you are downloading the data from an API, it is recommended to always use dynamic as you may not know what is being shipped and what is not and you then check it on the runtime;
dynamic skips compile time type checking, but to make sure data exists, we use
if...else
branching to load the data, or show an error message if the data does not exist.
For more on this, please read my article,
From zero to hero in JSON with C#[
^] and specially an answer at the bottom of the article that talks specifically about this problem.