#1 2025-01-05 12:53:53

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

Json de-serialization and TDate datatype

Hello,

I am using Delphi 12.2 and mORMot2 from September 24, 2024

As to my tests below code sample is not de-serialized

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

type
  TTest = packed record
    adate: TDate;
  end;

procedure TForm1.Button1Click(Sender: TObject);
const
  cTest = '{"adate":"2025-01-01"}';
var
  LData: TTest;
begin
  mormot.core.json.RecordLoadJson(LData, RawUtf8(cTest), TypeInfo(TTest));
end;

The same json string can be de-serialized if I change TDate -> TDateTime in record.

I wonder if TDate datatype is not supported?

Thanks & Regards,
Ertan

Offline

#2 2025-01-05 14:05:09

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

Re: Json de-serialization and TDate datatype

It is supported with the current mORMot 2 trunk.

Offline

#3 2025-01-05 14:40:34

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

Re: Json de-serialization and TDate datatype

Tested and found no problems.
Thank you.

Offline

#4 2025-01-06 02:31:52

vga
Member
Registered: 2016-08-18
Posts: 17

Re: Json de-serialization and TDate datatype

how about :    cTest = '[{"adate":"2025-01-01","name":"abc", "age":20},{"adate":"2025-01-02","name":"json", "age":12} ]';

Offline

#5 2025-01-18 02:18:05

vga
Member
Registered: 2016-08-18
Posts: 17

Re: Json de-serialization and TDate datatype

oh,
aTestDynArray:  array of TTTest;
DynArrayLoadJson(aTestDynArray, cTest, TypeInfo(array of TTTest));

Last edited by vga (2025-01-18 02:21:42)

Offline

Board footer

Powered by FluxBB