-
Notifications
You must be signed in to change notification settings - Fork 7
Closed
Labels
rev: OngoingWhen a reported issue was able to be reproduced and is currently being worked onWhen a reported issue was able to be reproduced and is currently being worked onsec: APIIssues that happen with the API feature of the packageIssues that happen with the API feature of the packageseg: ServerIssues that happen on the Server side of the packageIssues that happen on the Server side of the packagevcs: New FeatureWhen the issue represents a new feature for the projectWhen the issue represents a new feature for the project
Milestone
Description
Descrição da Sugestão
Melhorar a conversão de Dataset para JSON simplificando o código existente para usar .ToJSON, com uso de classhelper para versões que suportam e outro modo mais verboso para versões que não suportam
Anexos
Hoje o código é assim:
procedure TRALApplication.DatabaseToJSON(ARequest: TRALRequest;
AResponse: TRALResponse);
var
query: TFDQuery;
RALSJ: TRALStorageJSON;
AStream: TStringStream;
begin
query := TFDQuery.create(nil);
RALSJ := TRALStorageJSON.Create;
AStream := TStringStream.Create;
try
// faz algo com a query
// query.blablablabla
// converte a query para stream
RALSJ.SaveToStream(query, AStream);
// responde o stream
AResponse.Answer(HTTP_OK, AStream, rctAPPLICATIONJSON);
finally
RALSJ.Free;
query.Free;
end;
end;Modificar para algo como
Com Helper:
procedure TRALApplication.DatabaseToJSON(ARequest: TRALRequest;
AResponse: TRALResponse);
var
query: TFDQuery;
begin
query := TFDQuery.create(nil);
try
// faz algo com a query
// query.blablablabla
// responde o json, versões com Helper
AResponse.Answer(HTTP_OK, query.ToJSON, rctAPPLICATIONJSON);
finally
query.Free;
end;
end;Sem Helper:
procedure TRALApplication.DatabaseToJSON(ARequest: TRALRequest;
AResponse: TRALResponse);
var
query: TFDQuery;
RALSJ: TRALStorageJSON;
begin
query := TFDQuery.create(nil);
RALSJ := TRALStorageJSON.Create;
try
// faz algo com a query
// query.blablablabla
// responde o json, versões sem Helper
AResponse.Answer(HTTP_OK, RALSJ.DataSetToJSON(query), rctAPPLICATIONJSON);
finally
RALSJ.Free;
query.Free;
end;
end;Motivo da Mudança
No response
Informações adicionais
No response
Relator do Problema
No response
Metadata
Metadata
Assignees
Labels
rev: OngoingWhen a reported issue was able to be reproduced and is currently being worked onWhen a reported issue was able to be reproduced and is currently being worked onsec: APIIssues that happen with the API feature of the packageIssues that happen with the API feature of the packageseg: ServerIssues that happen on the Server side of the packageIssues that happen on the Server side of the packagevcs: New FeatureWhen the issue represents a new feature for the projectWhen the issue represents a new feature for the project