You are not logged in.
Pages: 1
I can't get RecordLoadJSON to work with records containing TTimeLog.
But it seems to work if TTimeLog is defined as int64 (using delphi 2007).
I've put an example program below.
program test;
{$APPTYPE CONSOLE}
uses
SysUtils, SynCommons;
type
myJSON = packed record
myDate: TTimeLog;
s: string; //added to create some TypeInfo
end;
const
__myJSON = 'myDate:TTimeLog; s:string';
testString = '{"myDate":135305815903}';
var
myRecord: myJSON;
begin
TTextWriter.RegisterCustomJSONSerializerFromText(TypeInfo(myJSON),__myJSON);
RecordLoadJSON(myRecord,testString,TypeInfo(myJSON));
writeln(DateToStr(TimeLogToDateTime(myRecord.myDate))); //outputs 12/30/1899
//if myDate is defined as an Int64 then output is correct - 4/14/2016
writeln(DateToStr(TimeLogToDateTime(135305815903))); //outputs 4/14/2016
readln;
end.
Is this a bug?
Offline
There was indeed a problem.
In text-based serialization, TTimeLog was serialized as ISO-8601 text, whereas it should have been serialized as plain Int64.
Just like with TJSONSerializer (i.e. class serialization).
Should be fixed by http://synopse.info/fossil/info/6e2fdf56bd
Thanks for the feedback!
Offline
Thanks
Offline
Pages: 1