Assigning data from JSON response to XDWebDataset

I tried to read all related topics but still can not make this thing working for me. I have the bellow JSON response from my server, which, as i understand, is not a json array but i cannot find a way to convert it to one to use in SETJSONDATA method of xdatawebdataset. Looks like it comes as string.

This is one example of my attempts: TJSArray(TJSJSON.parse(String(Response.Result)))
It doesn't load anything. Just adds an empty record.
Can you advice please.

In xdataserver:
procedure to execute the query and load to stream in json format:

procedure TMainForm.GetQueryData(MStream: TMemoryStream);
begin
if Assigned(MStream)
then begin
qryGenQuery.close;
qryGenQuery.open;
qryGenQuery.SaveToStream(MStream, sfJson);
end;
end;

Service function which i call from the client:

function TReportService.Runquery(S: string): TStream;
var LResult: TMemoryStream;
begin
LResult := TMemoryStream.create;
mainform.qryGenQuery.SQL.Text := S;
mainform.GetQueryData(LResult);
Result := LResult;
end;

The REPONSE.RESULT

{"FDBS":{"Version":15,"Manager":{"UpdatesRegistry":true,"TableList":[{"class":"Table","Name":"qryGenQuery","SourceName":"patients","SourceID":1,"TabID":0,"EnforceConstraints":false,"MinimumCapacity":50,"ColumnList":[{"class":"Column","Name":"P_PID","SourceName":"P_PID","SourceID":1,"DataType":"AnsiString","Size":64,"Searchable":true,"Base":true,"OInUpdate":true,"OInWhere":true,"OInKey":true,"OriginColName":"P_PID","SourcePrecision":64,"SourceSize":64},{"class":"Column","Name":"FIRSTNAME_DCR","SourceName":"FIRSTNAME_DCR","SourceID":2,"DataType":"AnsiString","Size":128,"Searchable":true,"AllowNull":true,"ReadOnly":true,"Base":true,"OAllowNull":true,"OReadOnly":true,"OInUpdate":true,"OInWhere":true,"OriginColName":"FIRSTNAME_DCR","SourcePrecision":128,"SourceSize":128},{"class":"Column","Name":"LASTNAME_DCR","SourceName":"LASTNAME_DCR","SourceID":3,"DataType":"AnsiString","Size":128,"Searchable":true,"AllowNull":true,"ReadOnly":true,"Base":true,"OAllowNull":true,"OReadOnly":true,"OInUpdate":true,"OInWhere":true,"OriginColName":"LASTNAME_DCR","SourcePrecision":128,"SourceSize":128}],"ConstraintList":[],"ViewList":[],"RowList":[{"RowID":0,"Original":{"P_PID":"0000123","FIRSTNAME_DCR":"test","LASTNAME_DCR":"test"}},{"RowID":1,"Original":{"P_PID":"016417","FIRSTNAME_DCR":"CRYSTAL","LASTNAME_DCR":"WONSER"}},{"RowID":2,"Original":{"P_PID":"1","FIRSTNAME_DCR":"test2","LASTNAME_DCR":"test3"}},{"RowID":3,"Original":{"P_PID":"10028","FIRSTNAME_DCR":"DENNIS","LASTNAME_DCR":"FIELDS"}},{"RowID":4,"Original":{"P_PID":"10065","FIRSTNAME_DCR":"LINDA","LASTNAME_DCR":"SMITH"}},{"RowID":5,"Original":{"P_PID":"10072","FIRSTNAME_DCR":"JESSICA","LASTNAME_DCR":"SEBASTIAN PEDRO"}},{"RowID":6,"Original":{"P_PID":"10131","FIRSTNAME_DCR":"THOMAS","LASTNAME_DCR":"JANER"}},{"RowID":7,"Original":{"P_PID":"10176","FIRSTNAME_DCR":"CAMERON","LASTNAME_DCR":"BYERS"}},{"RowID":8,"Original":{"P_PID":"10216","FIRSTNAME_DCR":"JOLENA","LASTNAME_DCR":"JORDAN"}},{"RowID":9,"Original":{"P_PID":"10277","FIRSTNAME_DCR":"DEBORAH","LASTNAME_DCR":"ROBERTS"}}]}],"RelationList":[],"UpdatesJournal":{"Changes":[]}}}}

1 Like

The issue is fixed. Thanks to Wagner's explanations in the post TWebCore and XDATA

Thank you

1 Like

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