procedure THeaderFooterForm.OnAfterRequest;
var
RetObject: TJSONObject;
RetData: TJSONObject;
MResult: TJSONObject;
Loader: TImageLoaderThread;
Thumbnail: TJSONObject;
begin
try
RetObject := TJSONObject.ParseJSONValue(RESTResponse1.Content)
as TJSONObject;
RetData := RetObject.GetValue('data') as TJSONObject;
MResult := (RetData.GetValue('results') as TJSONArray).Get(0)
as TJSONObject;
Thumbnail := MResult.GetValue('thumbnail') as TJSONObject;
Text1.Text := MResult.GetValue('name').Value;
// TImageLoaderThread is a custom class to retrieve the image in a background thread
// and 2 anonymous methods to notify when thread finish download image and when bitmap is ready
Loader := TImageLoaderThread.Create(true, nil, OnBitmapLoaded);
Loader.ImgURL := Thumbnail.GetValue('path').Value + '.' +
Thumbnail.GetValue('extension').Value;
Loader.Start;
finally
StopWait;
end;
end;
Access The Marvel Developer API With REST And JSON In Delphi XE6 Firemonkey On Android And IOS
