XDataWebDataSet from Json (list)

Hello,

I receice a list of event in a json response but my xdatawebdataset return only 1 record.

   await(XDataWebConnection1.OpenAsync);

 
Response:= await(XDataWebClient1.RawInvokeAsync('IPlanningService.getEvents',[]));
       webmemo1.Lines.Add(Response.ResponseText);

        xevent.SetJsonData(Response.Result);

        xevent.Open;
        //xevent.recordcount = 1 

My json :
{
"value": [
{
"$id": 1,
"@xdata.type": "XData.Default.Event",
"Clef": 288,
"DESCRIPTION": "",
"SUMMARY": "",
"LOCATION": ""
},
{
"$id": 2,
"@xdata.type": "XData.Default.Event",
"Clef": 289,
"DESCRIPTION": "",
"SUMMARY": "",
"LOCATION": ""
},
{
"$id": 3,
"@xdata.type": "XData.Default.Event",
"Clef": 290,
"DESCRIPTION": "",
"SUMMARY": "",
"LOCATION": ""
}
]
With the debugger, i can see isarray return false and length = 1

image

Thank you.

Have you tried:

       xevent.SetJsonData(TJSObject(Response.Result)['value']);

?

+1 Thank you

Now, i have all my records.

But where can i found the documentation about this cast

Note that your JSON result is a JSON object with a property named "value", and that property holds a JSON array of objects.
Thus, you should cast the result to an object and get the content of the value property.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.