Skip to content

TJSONIniFile

Ini file implementation using JSON storage format

Declaration

Source position: jsonini.pp line 37

type

  TJSONIniFile = class(TCustomIniFile)
  public
    constructor Create(const AFileName: string; 
                  AOptions: TIniFileOptions=[]); overload;
    constructor Create(AStream: TStream; AOptions: TJSONOptions); overload;
    destructor Destroy;
    class procedure ConvertIni;
    function ReadString : string;
    function ReadInteger : LongInt;
    function ReadInt64 : Int64;
    function ReadBool : Boolean;
    function ReadDate : TDateTime;
    function ReadDateTime : TDateTime;
    function ReadFloat : Double;
    function ReadTime : TDateTime;
    procedure WriteString;
    procedure WriteDate;
    procedure WriteDateTime;
    procedure WriteFloat;
    procedure WriteTime;
    procedure WriteInteger;
    procedure WriteInt64;
    procedure WriteBool;
    procedure ReadSection;
    procedure ReadSections;
    procedure ReadSectionValues; overload;
    procedure EraseSection;
    procedure DeleteKey;
    procedure UpdateFile; overload;
    procedure UpdateFile(const AFileName: string); overload;
    property Stream: TStream; {r}
    property CacheUpdates: Boolean; {rw}
  end;

Description

TJSONIniFile is a descendant of TCustomIniFile that stores configuration data in JSON format instead of traditional ini file format. The JSON structure uses objects for sections and key-value pairs within those objects for the actual configuration entries. This allows for more flexible data storage while maintaining full compatibility with the standard ini file interface.

Properties

Member Visibility Description
CacheUpdates public Controls when changes are written to file
Stream read only public Read-only access to the internal stream
See all Properties

Methods

Member Visibility Description
ConvertIni public Converts a traditional ini file to JSON format
Create public Creates a new TJSONIniFile instance
DeleteKey public Removes a key from a section
Destroy public Destroys the TJSONIniFile instance
EraseSection public Removes an entire section from the JSON ini file
ReadBool public Reads a boolean value from the JSON ini file
ReadDate public Reads a date value from the JSON ini file
ReadDateTime public Reads a date-time value from the JSON ini file
ReadFloat public Reads a floating-point value from the JSON ini file
ReadInt64 public Reads a 64-bit integer value from the JSON ini file
ReadInteger public Reads an integer value from the JSON ini file
ReadSection public Reads all key names from a section
ReadSections public Reads all section names from the JSON ini file
ReadSectionValues public Reads all key-value pairs from a section
ReadString public Reads a string value from the JSON ini file
ReadTime public Reads a time value from the JSON ini file
UpdateFile public Writes the JSON data to file
WriteBool public Writes a boolean value to the JSON ini file
WriteDate public Writes a date value to the JSON ini file
WriteDateTime public Writes a date-time value to the JSON ini file
WriteFloat public Writes a floating-point value to the JSON ini file
WriteInt64 public Writes a 64-bit integer value to the JSON ini file
WriteInteger public Writes an integer value to the JSON ini file
WriteString public Writes a string value to the JSON ini file
WriteTime public Writes a time value to the JSON ini file
See all Methods

See also

Name Description
TCustomIniFile Abstract ini file object.
TMemIniFile Inifile cached in memory.