I receive this JSON response:
{
"status": "Ok",
"total": 105373,
"result": [
{
"id": 668839,
"cn": "A-12157-68812",
"pD": "09-12-2012",
"cCD": "06-05-2012",
"cT": "PERM",
"fN": "COMCAST CABLE COMMUNICATIONS, LLC",
"s": "NJ",
"cR": "Certified",
"pT": "ENGINEER 3",
"vC": 6,
"cddt": "html"
},
{
"id": 725695,
"cn": "A-12361-25668",
"pD": "05-28-2013",
"cCD": "12-26-2012",
"cT": "PERM",
"fN": "L'ONVIE INC.",
"s": "NY",
"cR": "Certified",
"pT": "Biochemist",
"vC": 6,
"cddt": "html"
},
{
"id": 0,
"cn": "A-11199-93239",
"pD": "05-31-2012",
"cCD": "07-18-2011",
"cT": "PERM",
"fN": "ROCKWELL AUTOMATION, INC.",
"s": "PR",
"cR": "Certified",
"pT": "Marketing Managers",
"vC": -1
}]
}
- What is the best way to convert this into an object so that I can apply various LINQ transforms to query for some meaningful data?
What is the efficient way to do this?
Should I create classes like:
public class Status {
string Status {get; set;}
int Total {get; set;}
IEnumerable<Result> Results {get; set;}
}
public class Result {
string Id {get; set;}
..................
}
And then figure out mapping/casting?
Try Json.NET. Check out this docs about LINQ queries. You can even use Json.NET to map your JSON to .NET objects automatically.