Open am2801 opened 4 years ago
Hi, @am2801, why didn't you implement code as in FromInt64() ?
stNull:
begin
TValue.Make(nil, TypeInfo, Value);
TValueData(Value).FAsSInt64 := SODefaultIntNull;
result := true;
end;
Hi again, @am2801, I took a closer look at your request. It doesn't fail current tests and seeems to be ok, but I suggest:
Please feel free to contact me with my account e-mail.
type
TTestFloat = class(TObject)
public
a: Single;
b: Double;
d: Double;
end;
procedure TTestSuperObjectUnMarshal.TestNullFloat;
var
json: string;
t: TTestFloat;
begin
json := '{"a": 0.1234567, "b": 0.123456789012345, "d": null}';
SODefaultFloatNull := 0.001;
t := UnMarshal<TTestFloat>(json);
try
checkEquals(t.a, 0.1234567, 0.00000001, 'Failed on single');
checkEquals(t.b, 0.123456789012345, 0.0000000000000001, 'Failed on double');
checkEquals(t.d, SODefaultFloatNull, 0.0001);
finally
t.free;
end;
end;
I want to receive the Json-element "customfield_11111":13.0, into the structure customfield_11111: double; // jobsize That works fine, but sometimes I receive "customfield_11111":null, and get a ”Marshalling error”. With this correction I am able to receive a zero instead of a marshalling error.