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

AndroidAppmethodCode SnippetDelphiFiremonkeyIOSOSXWindows

Convert INI Files To JSON And Back With XSuperObject In Delphi XE6 Firemonkey On Android And IOS

Delphi XE6 Firemonkey JSON IniFile Parse Convert TranslateOne of the useful settings storage components that comes with Delphi XE6 Firemonkey is TIniFile (and TMemIniFile). The format of an INI file is basically sections that contain name value pairs. You can have multiple sections and then multiple name value pairs in each section. In order to make the data you are storing in INI files more versatile you may want to be able to convert your INI file format into JSON format and back again. I use the XSuperObject library for handling the JSON half of the conversion because it works on Android, IOS, OSX, and Windows. It should also work in Delphi XE5 and AppMethod as well. There have been some updates to XSuperObject as of early May 2014 so if you have an earlier version you should update it. Here are four functions which will do the conversion for you. Two of them are for reading and writing a JSON array to and from an IniFile and two of them are for reading and writing a JSON object to and from an IniFile. The functions are not veriy extensive because they really only handle one layer of JSON objects. If you want to handle more than one layer or if you want to handle subsections in INI files you’ll have to extend the functions yourself. Additionally, the functions support a limited number of datatypes but I usually just use strings everywhere in my INI files and JSON data.

Head over and download the latest version of XSuperObject which is required to use the JSON to INI file functions.


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

Related posts

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


DelphiCon 2020 FireMonkey Sessions Available Starting November 19


Powerful Commercial Gorilla3D Framework Upgraded For Delphi FireMonkey On Windows And Android

Sign up for our Newsletter and
stay informed

Leave a Reply