First.. I'm not interested in JSON.NET or any other parsers. Only DataContractJsonSerializer
I have to work with structures I get and send to REST API and they look like so:
{ "records": [
{
"attributes": {
"OBJECTID": 1,
"Address": "380 New York St.",
"City": "Redlands",
"Region": "CA",
"Postal": "92373"
}
},
{
"attributes": {
"OBJECTID": 2,
"Address": "1 World Way",
"City": "Los Angeles",
"Region": "CA",
"Postal": "90045"
}
}
]
What we can see is something like this:
class SomeData
{
public List<SomeRecord> Records { get; set; }
}
class SomeRecord
{
public List<KeyValuePair<string, string>> Attributes { get; set; }
}
How do I attribute my object so serializer can produce structure like this? Or should I create object with properties covering each attribute?
Problem is - this webservice seem to be attributes here and there and I'm not even sure of all possible names. So, List of KVP seems like a good choice, but it doesn't work for me.