❔ JSON serialization fails

After the serialization 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; }
}


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"
    }
  }
}
Was this page helpful?