Im not sure this can be done, basically I’m struggling to map c# objects to a json feed.
the problem is the json text contains a object name that is actually a unique id meaning I cant simply use a single object for the mapping.
{
"Persons": {
"12345": {
"surname": "smith",
"firstname": "jim"
"language": "en"
},
"99999": {
"surname": "blog",
"firstname": "joe"
"language": "en"
},
"87534": {
"surname": "bond",
"firstname": "james"
"language": "en"
}
}
}
the object structure I have is a class called Persons containing a IList property.
As you can see the object names are actually unique id’s, but could be the same type.
I dont have control over the json feed so I cant simply edit that end.
Is there anything I can do to fix this in json.net? maybe a attribute???
I’m not a JSON.NET user so I apologize if this doesn’t apply. Your JSON structure appears that it would better match a
Dictionary<int, Person>collection wherePersonis defined:Hierarchical data structures typically don’t mesh well with
List<T>collections.