#1 2025-02-09 19:55:19

ertank
Member
Registered: 2016-03-16
Posts: 178

TTime support for json operations

Hello,

Below example fails using Delphi 12.

uses
  mormot.core.json, mormot.core.base;

type TRec = packed record id: Integer; atime: TTime; end;

procedure TForm1.FormCreate(Sender: TObject);
const cData = '{id:123,atime:"15:30"}';
var LRec: TRec;
begin
  if not mormot.core.json.RecordLoadJson(LRec, RawUtf8(cData), TypeInfo(TRec)) then
    ShowMessage('not ok')
  else
    ShowMessage('deserialize completed');
end;

I know I can use TDateTime instead. Just asking for convenience. Is it possible to support TTime data type?

Thank you for your consideration.

Regards,
Ertan

Offline

#2 2025-02-10 07:37:51

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,933
Website

Re: TTime support for json operations

Yes, following ISO encoding, e.g. 'T15:30:00', and a TDateTime if TTime is not recognized.

Offline

Board footer

Powered by FluxBB