I am working with some ugly Json. I believe it was converted from XML so the Json properties are not as expected.
"response": {
"EventType": "SomeEvent",
"data": {
"Markets": {
"market": [{
"@name": "Derby Dash",
"Players": {
"Player": [{
"@name": "Joe Soap",
"@value": "15",
"@categoryId": "1",
"@categoryDesc": "runner",
"#text": "30"
},
{
"@name": "Jolene Soap",
"@value": "15",
"@categoryId": "1",
"@categoryDesc": "runner",
"#text": "31"
},
So the first thing i do is convert the json to dynamic
:
var jsonObject = JsonConvert.DeserializeObject<dynamic>(json);
I am then able to get all the data until such point where the property is prefixed with an @
.
foreach (var market in jsonObject.response.data.Markerts)
{
var marketInfo = new Market
{
Players = new List<PlayerInfo>(),
Name = market. // How on earth do i get this property ????
};
}
You will also notice another property prefixed with a #
. That i also do not know how to get.