Closed GoogleCodeExporter closed 9 years ago
I looked into the source code of x-superobject to see if I could fix the
problem.
I isolated the handling of the 'TDateTime' type so that the date string gets
parsed in a different way.
To parse the ISO 8601 date I used a unit found here:
http://wiert.me/2011/07/19/iso-8601-delphi-way-to-convert-xml-date-and-time-to-t
datetime-and-back-via-stack-overflow/.
I dont know if this fix is acceptable for x-superobject, it introduces a
dependency with a (small) unit.
And I dont know if this change has any unknown side effects.
I attached a .rar archive that contains my full code, it contains a form with a
button that deserializes a object from JSON with a Zulu date time and shows
that the date gets parsed correctly.
This is what the change looks like in 'XSuperObject.pas' around line 1880:
if (RType = TypeInfo(TDate)) or (RType = TypeInfo(TTime)) then begin
SetValue<Typ>(Data, MemberValue, Member, TValue.From<TDateTime>(IJSONData.Ancestor[Member].AsVariant));
end
else if (RType = TypeInfo(TDateTime)) then begin
SetValue<Typ>(
Data,
MemberValue,
Member,
TValue.From<TDateTime>(
TIso8601.DateTimeFromIso8601(
IJSONData.Ancestor[Member].AsVariant
)
)
);
end
// Continues with a switch
Original comment by Rein.Ver...@gmail.com
on 15 Aug 2014 at 8:40
Attachments:
This issue was closed by revision r72.
Original comment by onryld...@gmail.com
on 18 Aug 2014 at 1:27
Original issue reported on code.google.com by
Rein.Ver...@gmail.com
on 15 Aug 2014 at 4:09