I'm using TWebHttpRequest to get a list of staff members from the server.
I'm using a TXDataWebDataSet to hold the fetched data. I am receiving the JSON from my XData server and this is working correctly. The example json is below.
What do I need to do inside the RequestResponse event to load the json into the TXDataWebDataSet? If you could also include any checking for errors so I can make sure I'm using best practices and catching errors etc.
procedure TwfStaff.reqStaffRequestResponse(Sender: TObject; ARequest: TJSXMLHttpRequestRecord; AResponse: string);
begin
***** how do I code this to load the TXDataWebDataSet (with error checking)
end;
Cheers,
Paul
The JSON being returned is:
{
"$id": 1,
"@xdata.type": "xdcClasses.TStaffList",
"staff": [
{
"$id": 2,
"@xdata.type": "xdcClasses.TStaffs",
"STAFFID": 52,
"STAFF_FIRST": "David",
"STAFF_SURNAME": "Allison",
"EMAIL": "dave@westnet.com.au",
"USER_NAME": "dave@westnet.com.au",
"IS_ADMIN": false,
"IS_ACTIVE": true
},
{
"$id": 3,
"@xdata.type": "xdcClasses.TStaffs",
"STAFFID": 9,
"STAFF_FIRST": "Tanya",
"STAFF_SURNAME": "Batt",
"EMAIL": "paul@pacsoftware.com.au",
"USER_NAME": "tanya",
"IS_ADMIN": true,
"IS_ACTIVE": true
},
{
"$id": 4,
"@xdata.type": "xdcClasses.TStaffs",
"STAFFID": 26,
"STAFF_FIRST": "Ian",
"STAFF_SURNAME": "Bradshaw",
"EMAIL": "ian.bradshaw@tpg.com.au",
"USER_NAME": "ian.bradshaw",
"IS_ADMIN": false,
"IS_ACTIVE": true
}
]
}