You are not logged in.
ObjectLoadJSON cannot load a TDateTimeTS field, like the following (which was saved using ObjectToJSON).
{"ID":0,"CreateTime":"2021-05-20T21:21:20.819"}
Bug?
Offline
TDateTimeTS ?
Where do you think the problem comes from?
Yes. I meant TDateTimeMS.
The problem of ObjectLoadJSON ended up in this part of code: mormot.core.rtti, LINE 3305-3309
function TRttiProp.SetValue(Instance: TObject; const Value: variant): boolean;
var
k: TRttiKind;
v64: Int64;
f64: double;
u: RawUtf8;
begin
result := false; // invalid or unsupported type
k := TypeInfo.Kind;
if k in rkOrdinalTypes then
if VariantToInt64(Value, v64) then
SetInt64Value(Instance, v64)
else
exit
else if k in rkStringTypes then
if VarIsEmptyOrNull(Value) then // otherwise would set 'null' text
SetAsString(Instance, '')
else if VariantToUtf8(Value, u) then
SetAsString(Instance, u)
else
exit
else if k = rkFloat then
if VariantToDouble(Value, f64) then // <<--- the value is a DateTime string "2021-05-20T21:21:20.819", but the code is trying to convert it to a Double.
SetFloatProp(Instance, f64)
else
exit
else if k = rkVariant then
SetVariantProp(Instance, Value)
else
exit;
result := true;
end;
Last edited by wxinix (2021-05-21 13:10:02)
Offline
Are you using a setter method for the TDateTimeMS property?
This case was not properly handled - direct property from the field should work as expected.
I just tried to fix the problem.
Offline
Yes. The TDateTimeMS field has a setter.
Last edited by wxinix (2021-05-21 16:21:18)
Offline