Http get json into string
delphi, delphi-7, idhttp, indy, json
Solution
I found a solution. That code works perfect.
function GetURLAsString(aURL: string): string;
var
lHTTP: TIdHTTP;
lStream: TStringStream;
begin
lHTTP := TIdHTTP.Create(nil);
lStream := TStringStream.Create(Result);
try
lHTTP.Get(aURL, lStream);
lStream.Position := 0;
Result := lStream.ReadString(lStream.Size);
finally
FreeAndNil(lHTTP);
FreeAndNil(lStream);
end;
end;
Problem
I'm trying to get json response via HTTP GET method to a string but all I got is that: I'm using a code like that: ``` memo1.Text:= idhttp1.Get('http://blabla.com/bla.php'); ``` it returns json data. i need to get that json response to memo1. How can I do that?