From 0dbb8207ccca8b6a1046cdb9f0955ac4bcd65774 Mon Sep 17 00:00:00 2001 From: CarlosHe Date: Tue, 22 Dec 2020 19:43:36 -0300 Subject: [PATCH] Correction in encoding --- src/Horse.Jhonson.pas | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Horse.Jhonson.pas b/src/Horse.Jhonson.pas index 752c85c..f05af07 100644 --- a/src/Horse.Jhonson.pas +++ b/src/Horse.Jhonson.pas @@ -58,7 +58,11 @@ procedure Middleware(Req: THorseRequest; Res: THorseResponse; Next: {$IF DEFINED if Assigned(LContent) and LContent.InheritsFrom({$IF DEFINED(FPC)}TJsonData{$ELSE}TJSONValue{$ENDIF}) then begin - LWebResponse.Content := {$IF DEFINED(FPC)}TJsonData(LContent).AsJSON {$ELSE}{$IF CompilerVersion > 27.0}TJSONValue(LContent).ToJSON{$ELSE}TJSONValue(LContent).ToString{$ENDIF}{$ENDIF}; + {$IF DEFINED(FPC)} + LWebResponse.ContentStream := TStringStream.Create(TJsonData(LContent).AsJSON); + {$ELSE} + LWebResponse.Content := {$IF CompilerVersion > 27.0}TJSONValue(LContent).ToJSON{$ELSE}TJSONValue(LContent).ToString{$ENDIF}; + {$ENDIF} LWebResponse.ContentType := 'application/json; charset=' + Charset; end; end;