Hi,
I tried to use TArray instead of TList from:
https://support.tmssoftware.com/t/json-value-when-function-response-is-tlist-myclasstype/14706
, but the answer is still with value,(below answer)
{
"value": [
{
"$id": 1,
"id": "067D821D-684E-472B-AD68-E4A6FFCFC098",
"testvar": "",
"OrganisationName": "ORG1"
},
{
"$id": 2,
"id": "EEA94E66-6648-4EAD-8DD9-0BA1D7A69735",
"testvar": "",
"OrganisationName": "ORG2"
}
]
}
I would need:
[
{
"$id": 1,
"id": "067D821D-684E-472B-AD68-E4A6FFCFC098",
"testvar": "",
"OrganisationName": "ORG1"
},
{
"$id": 2,
"id": "EEA94E66-6648-4EAD-8DD9-0BA1D7A69735",
"testvar": "",
"OrganisationName": "ORG2"
}
]
[Route('organisations-get')]
[HttpGet] function GetOrganisations:TArray<T_Organisation>;
function TAVSessionService.GetOrganisations:TArray<T_Organisation>;
begin
LogServerRequest(TXDataOperationContext.Current.Request);
Setlength(Result,2);
Result[0] := T_Organisation.Create;
Result[0].OrganisationName := 'ORG1';
Result[0].Id := StringToGUID('{067D821D-684E-472B-AD68-E4A6FFCFC098}');
Result[1] := T_Organisation.Create;
Result[1].OrganisationName := 'ORG2';
Result[1].Id := StringToGUID('{EEA94E66-6648-4EAD-8DD9-0BA1D7A69735}');
//TrowNotImplemented;
end;
Second question is how to ignore from JSON response testvar, I tried [XDataExcludeProperty, JsonIgnore]
[Entity, Automapping]
T_Organisation = class
strict private
Fid: TGUID;
[XDataExcludeProperty, JsonIgnore]
Ftestvar : string;
public
OrganisationName : string;
property Id: TGUID read FId write FId;
[XDataExcludeProperty, JsonIgnore]
property testvar:string read Ftestvar write Ftestvar;
end;
Thanks a lot,
Mihai