Anurag Malani

Anurag Malani

  • NA
  • 80
  • 34.6k

How to deserialize a object type class in linq

May 25 2014 6:09 AM
Hi All,
My Qus is how can we deserialize "Scorers" object type class by LINQ, bcoz some time "Scorers => home & away" data is blank like a string and some times it contains data in array form with the Scorers names..
below is my class and json data, Please help...
My Class -
public class Scorers
{
public object home { get; set; }
public object away { get; set; }
}
public class Schedule
{
public Scorers scorers { get; set; }
}
public class Matches
{
public List<Schedule> schedules { get; set; }
}
public class RootObject
{
public Matches matches { get; set; }
}
My json -
{
"matches": {
"schedules": [
{
"scorers": {
"home": "",
"away": ""
}
},
{
"scorers": {
"home": "",
"away": ""
}
},
{
"scorers": {
"home": [
{
"name": "ABC",
},
{
"name": "DEF",
}
],
"away": [
{
"name": "PQR",
},
{
"name": "STU",
}
]
}
}
]
}
}

Answers (1)