unit fmainForm;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses XSuperObject;
procedure TForm1.FormCreate(Sender: TObject);
var fileContents : string;
job: ISuperObject;
LDate: TDate;
LValue: string;
LFormat: TFormatSettings;
LDouble: Double;
begin
fileContents := '{' +
' "Id": "POS-1",' +
' "Employer": {' +
' "Name": {' +
' "Normalized": "Acme"' +
' }' +
' },' +
' "IsSelfEmployed": false,' +
' "IsCurrent": true,' +
' "StartDate": {' +
' "Date": "2020-03-01",' +
' },' +
' "EndDate": {' +
' "Date": "2021-06-08",' +
' },' +
'}';
job := SO(fileContents);
if Assigned(job['Id']) then
Memo1.Lines.Add('Job Id = ' + job['Id'].AsString);
if Assigned(job['Employer.Name.Normalized']) then
Memo1.Lines.Add('Employer name = ' + job['Employer.Name.Normalized'].AsString);
if Assigned(job['StartDate.Date']) then
Memo1.Lines.Add('Start date = ' + job['StartDate.Date'].AsString);
if Assigned(job['EndDate.Date']) then
Memo1.Lines.Add('End date = ' + job['EndDate.Date'].AsString);
end;
end.
Most of it works. E.g job['Id'].AsString
evaluates to 'POS-10'
, etc.
But job['StartDate.Date'].AsString
evaluates to '43891'
and EndDate to '44355'
. What am I doing wrong?
That's
Job Id = POS-1
Employer name = Acme
Start date = 43891
End date = 44355