Is it possible to deserialize a name as a value?
I've got some JSON like this:
{
"id": "106906",
"data": {
"SER1": {
"events": [
{
"timestamp": "2020-11-11T10:28:40.728600Z",
"type": "high"
}
]
},
"SER2": {
"events": [
{
"timestamp": "2020-11-11T10:28:40.728600Z",
"type": "high"
}
]
}
}
}
The C# classes I'm using are like this:
// Root myDeserializedClass = JsonConvert.DeserializeObject<Root>(myJsonResponse);
public class Event
{
public DateTime timestamp { get; set; }
public string type { get; set; }
}
public class Device
{
public string Id { get; set; }
public List<Event> events { get; set; }
}
public class Data
{
public List<Device> Devices { get; set; }
}
public class Root
{
public string id { get; set; }
public Data data { get; set; }
}
I want SER1 and SER2 to map to List<Device> Devices, with the Id of Device getting SER1 and SER2 respectively.
Is this possible?