The json spec allows for null values. However trying to deserialise a json string to a native delphi type causes an error when the json contains a null.
E.g. given a class
TMyClass = class
private
FValue: TDateTime;
published
property Value; TDateTime read FValue write FValue;
end;
/// and some code
procedure Parse(data: string);
var
Json: TJsonObject;
Obj: TMyClass;
begin
Json := TJsonObject.Parse(data) as TJsonObject;
Obj := TMyClass.Create;
Json.ToSimpleObject(Obj, false);
end;
and pass in
{"Value":null}
returns an error
Cannot cast object into DateTime.
The json spec allows for null values. However trying to deserialise a json string to a native delphi type causes an error when the json contains a null.
E.g. given a class
and pass in
{"Value":null}
returns an error Cannot cast object into DateTime.