'Deserialize Json with class names that are not always the same, in C#

I'm trying to deserialize a response from a firebase realtime database get/json, to get user locations that are online

example response:

{
  "test1": {
    "id": "test-1",
    "location": {
      "lat": 37.33097983,
      "long": -122.03063943
    }
  },
  "test2": {
    "id": "test-2",
    "location": {
      "lat": 37.33021864,
      "long": -122.02370753
    }
  },
  "test3": {
    "id": "test-3",
    "location": {
      "lat": 37.32873847,
      "long": -122.01980584
    }
  },
  "test4": {
    "id": "test-4",
    "location": {
      "lat": 37.32563464,
      "long": -122.01972943
    }
  },
  "test5": {
    "id": "test-5",
    "location": {
      "lat": 37.32472734,
      "long": -122.02127163
    }
  }
}

I put this into a json to c# class converter and it creates a class for each user (Test1, Test2, Test3, etc). This would work, if the users from the example are the only users to be in the response. If I had a sixth user named "6test", I would need to also create a class for that one too.

How can I use the Json converter (Newtonsoft.Json or System.Text.Json) to return a user in a list<User>



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source