Get access to over 100 FireMonkey cross platform samples for Android, IOS, OSX, Windows, and Linux!

AndroidAppmethodCode SnippetDelphiDemoFiremonkeyIOSOSXWindows

Access The Marvel Developer API With REST And JSON In Delphi XE6 Firemonkey On Android And IOS

| Delphi 11 10 XE8 XE7 XE Seattle Berlin Tokyo Rio Firemonkey Delphi Android Delphi IOS

Delphi XE6 Firemonkey Marvel Developer REST API Android Demo | Delphi 11 10 XE8 XE7 XE Seattle Berlin Tokyo Rio Firemonkey Delphi Android Delphi IOSDeveloper Daniele Spinetti has some code snippets up demonstrating how to access the Marvel Developer API with Delphi XE6 Firemonkey. The API is REST based and returns JSON which are easily access anded processed using the built in REST client components. I don’t see source code for the app itself but you should be able to easily build your own version using the code snippets. Basically it uses the HeaderFooter template and then a REST client component to download the data. Once the download is complete it uses TJSONObject to parse the returned JSON and set the various data to the fields on the form. I like this code snippet as it is a good example of the JSON parser in action in Delphi XE6 Firemonkey. It does use some custom code to load the thumbnail but you can get similar code to do that here and here. This code should work on all Firemonkey platforms which are Android, IOS, Windows, and OSX. Check out the JSON parser code snippet:

procedure THeaderFooterForm.OnAfterRequest;
RetObject: TJSONObject;
RetData: TJSONObject;
MResult: TJSONObject;
Loader: TImageLoaderThread;
Thumbnail: TJSONObject;
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 + '.' +

Head over and read the full blog post to check out the other code snippets and screenshots from the app.

Have Delphi Firemonkey questions? Ask and get answers on StackOverflow.

Related posts

Unleashing Creativity With Song Writer AI: A Deep Dive


How To Build Stable Diffusion Text To Image Prompts


FireMonkey 10.4.2 Features Updated iOS 14, Android 11, And macOS 11 Support Plus Hundreds Of Fixes


Ryzen 9 5950x: One Billion Lines Of Delphi Code Compiled In ~5 Minutes On 16 Cores

Sign up for our Newsletter and
stay informed

Leave a Reply