© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
7 replies
Cryptobax | ParallelNode

❔ JSON serialization fails

After the serialization
RiotChampionWrapper.Champions
RiotChampionWrapper.Champions
is null. The problem might be that each item has a different name. How can I fix it?
public class RiotChampionWrapper
{
    [JsonPropertyName("data")]
    private List<RiotChampion> Champions { get; set; }
}

public class RiotChampion
{
    [JsonPropertyName("id")]
    public string Id { get; set; }

    [JsonPropertyName("key")]
    public string Key { get; set; }

    [JsonPropertyName("name")]
    public string Name { get; set; }
}
public class RiotChampionWrapper
{
    [JsonPropertyName("data")]
    private List<RiotChampion> Champions { get; set; }
}

public class RiotChampion
{
    [JsonPropertyName("id")]
    public string Id { get; set; }

    [JsonPropertyName("key")]
    public string Key { get; set; }

    [JsonPropertyName("name")]
    public string Name { get; set; }
}


RiotChampionWrapper? items = JsonSerializer.Deserialize<RiotChampionWrapper>(data);
RiotChampionWrapper? items = JsonSerializer.Deserialize<RiotChampionWrapper>(data);


{
  "type": "champion",
  "format": "standAloneComplex",
  "version": "13.10.1",
  "data": {
    "Aatrox": {
      "id": "Aatrox",
      "key": "266",
      "name": "Aatrox"
    },
    "Ahri": {
      "id": "Ahri",
      "key": "103",
      "name": "Ahri"
    }
  }
}
{
  "type": "champion",
  "format": "standAloneComplex",
  "version": "13.10.1",
  "data": {
    "Aatrox": {
      "id": "Aatrox",
      "key": "266",
      "name": "Aatrox"
    },
    "Ahri": {
      "id": "Ahri",
      "key": "103",
      "name": "Ahri"
    }
  }
}
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ NodaTime JSON Serialization
C#CC# / help
2y ago
❔ ✅ JSON Serialization not working?
C#CC# / help
3y ago
Newtonsoft.Json Serialization Exception
C#CC# / help
3y ago
❔ JSON Serialization Weird Model
C#CC# / help
4y ago