I have a API that returns a JSON like the one below and I have to deserialize it in a C# object:
{
"found": true,
"resultsData": [
{
"2023-05-13": [
{
"info1": "Test",
"infoCode": 1,
"infos": [
{
"code": 2,
"extraInfo1": "test1",
"extraInfo2": "test2",
"extraInfo3": "test3",
"order": 1,
"risk": "",
"alarm": "alarm text"
},
{
"code": 3,
"extraInfo1": "test1",
"extraInfo2": "test2",
"extraInfo3": "test3",
"order": 1,
"risk": "",
"alarm": "alarm text"
},
{
"code": 4,
"extraInfo1": "test1",
"extraInfo2": "test2",
"extraInfo3": "test3",
"order": 1,
"risk": "",
"alarm": "alarm text"
},
{
"code": 5,
"extraInfo1": "test1",
"extraInfo2": "test2",
"extraInfo3": "test3",
"order": 1,
"risk": "",
"alarm": "alarm text"
}
]
}
]
},
{
"2023-05-14": [
{
"info1": "Test",
"infoCode": 2,
"infos": [
{
"code": 6,
"extraInfo1": "test1",
"extraInfo2": "test2",
"extraInfo3": "test3",
"order": 1,
"risk": "",
"alarm": "alarm text"
},
{
"code": 7,
"extraInfo1": "test1",
"extraInfo2": "test2",
"extraInfo3": "test3",
"order": 1,
"risk": "",
"alarm": "alarm text"
},
{
"code": 8,
"extraInfo1": "test1",
"extraInfo2": "test2",
"extraInfo3": "test3",
"order": 1,
"risk": "",
"alarm": "alarm text"
},
{
"code": 9,
"extraInfo1": "test1",
"extraInfo2": "test2",
"extraInfo3": "test3",
"order": 1,
"risk": "",
"alarm": "alarm text"
}
]
}
]
}
],
"message": ""
}
If the "2023-05-13" is inserted inside the object like a property it could easy to deserialize that into a object but because this isn't deserializable into POCO object and it's not possible to change the API response I try to find a solution. Following this article from Microsoft I understand that I can deserialize manually using System.Text.Json and the JsonNode object and read property and value in a cicle loop. I figure out how to obtain a Json node and object but I'm stucked for retrieve the "2023-05-13" value and the "2023-05-14" because they haven't a "name" like the others properties. Any help with some code to figure out will be much more than appreciated