unit MainForm;
{$mode delphi}
{$codepage UTF8}
interface
uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls, EditBtn, ComCtrls, Spin,
     windows, SimplyJSON;
type
  { TMainFrm }
  TMainFrm = class(TForm)
    ReadBtn: TButton;
    ExitBtn: TButton;
    JSONFileNameEd: TFileNameEdit;
    JSONFileNameEdLbl: TLabel;
    KeyEdt: TLabeledEdit;
    RecTypeEd: TRadioGroup;
    procedure ExitBtnClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure ReadBtnClick(Sender: TObject);
  private
  public
  end;
var
  MainFrm: TMainFrm;
implementation
{$R *.lfm}
{ TMainFrm }
procedure TMainFrm.ExitBtnClick(Sender: TObject);
begin
Application.Terminate;
end;
procedure TMainFrm.FormCreate(Sender: TObject);
begin
RecTypeEd.ItemIndex:= 0;
end;
procedure TMainFrm.ReadBtnClick(Sender: TObject);
var STitle, SMsg: String;
begin
if Trim(JSONFileNameEd.Text) = '' then
 begin
 Application.MessageBox(PChar('Поле "Имя файла" не заполнено!'), PChar('Ошибка!'), MB_ICONERROR);
 Abort;
 end;
if Trim(KeyEdt.Text) = '' then
 begin
 Application.MessageBox(PChar('Поле "Ключ" не заполнено!'), PChar('Ошибка!'), MB_ICONERROR);
 Abort;
 end;
case RecTypeEd.ItemIndex of
 0: begin
    STitle:= 'Строка';
    SMsg:= JSReadString(KeyEdt.Text, '???', JSONFileNameEd.Text);
    end;
 1: begin
    STitle:= 'Число';
    SMsg:= IntToStr(JSReadInteger(KeyEdt.Text, 0, JSONFileNameEd.Text));
    end;
 2: begin
    STitle:= 'Правда/Ложь';
    SMsg:= BoolToStr(JSReadBoolean(KeyEdt.Text, False, JSONFileNameEd.Text), 'Правда', 'Ложь');
    end;
 end;
Application.MessageBox(PChar(SMsg), PChar(STitle), MB_ICONASTERISK);
end;
end.
