I have a Json that looks as this:
{
"id": "1367",
"title": "ticket sample",
"custom_fields": {
"13084": {
"E0D4ED43": "South"
},
"13085": {
"F19DF0D6": "Atlanta"
},
"13089": {
"AF0EC62F": "Peter Johnson"
}
}
}
And to parse it, my class uses nested Dictionaries:
class incident
{
public string id { get; set; }
public string title { get; set; }
public Dictionary<int, Dictionary<string, string>> custom_fields { get; set; }
}
This works like a charme, until I've discovered that the custom fields are not always the same, for example I could receive:
{
"id": "1367",
"title": "ticket sample",
"custom_fields": {
"13084": {
"E0D4ED43": "South"
},
"13085": {
"F19DF0D6": "Atlanta"
},
"13086": "SAP",
"13088": {
"AE3ED01A": "Commercial"
}
}
}
If you look at the custom field "13086", it doesn't contains another object (it's just a string), so when I try to parse with the previous class it fails.
Those are examples of two different responses, but the keys received change a lot (that's why I used Dictionaries because I don't know how many and which will be received for each ticket)