I am looking to deserialize the below json string to 3 different DataGrids. One for Results, one for withdrawals and one for deposits. Anyone have a good method for doing this? Any help would be much appreciated.
{
"results": [
{
"id": "51142254",
"tp_id": "!XP4D49X0CD123628",
"firstname": "Owner",
"lastname": "Operator",
"email": "",
"phone": "",
"enrolled": "1",
"balance": 247.54,
"fleet": "Test Express",
"deposits": [
{
"id": "184022380",
"date": "2016-02-17",
"amount": "200.00",
"transID": "135246",
"memo": "Scheduled Deposit",
"status": "Cleared"
},
{
"id": "184022383",
"date": "2016-02-25",
"amount": "200.00",
"transID": "246357",
"memo": "Scheduled Deposit",
"status": "Cleared"
},
{
"id": "184022386",
"date": "2016-03-02",
"amount": "200.00",
"transID": "975468",
"memo": "Scheduled Deposit",
"status": "Cleared"
}
],
"withdrawals": [
{
"id": "184026949",
"date": "2016-03-09",
"amount": "352.46",
"transID": "395920",
"memo": "Invoice\r\n\r\n100234",
"status": "Cleared"
}
]
},
{
"id": "51142326",
"tp_id": "!XP4D49X7CD123612",
"firstname": "Owner",
"lastname": "Operator",
"email": "",
"phone": "",
"enrolled": "1",
"balance": 0,
"fleet": "Test\r\nExpress",
"deposits": [],
"withdrawals": []
}
]
}
When i go to json2chsarp.com this is what gets generated for my classes. I am assuming the deposits and withdrawals section are not showing up because the child nodes are not listed here. how should this be done correctly?
public class Result
{
public string id { get; set; }
public string tp_id { get; set; }
public string firstname { get; set; }
public string lastname { get; set; }
public string email { get; set; }
public string phone { get; set; }
public string enrolled { get; set; }
public double balance { get; set; }
public string fleet { get; set; }
public List<object> deposits { get; set; }
public List<object> withdrawals { get; set; }
}
public class RootObject
{
public List<Result> results { get; set; }
}