Add validation for JSON Null time field conversion.

This commit is contained in:
Ezequiel Juliano Müller 2016-09-02 11:12:53 -03:00
parent b760489777
commit bc425918b2
2 changed files with 15 additions and 13 deletions

@ -1 +1 @@
Subproject commit 943ccb22404ccf3f6e4a2f6ecd4cc0d9a3223c7e
Subproject commit ee1220423bb0cb99df71a5c958b4f69b5f69f2e5

View File

@ -2250,21 +2250,23 @@ begin
end
else if _field.PropertyType.QualifiedName = 'System.TTime' then
begin
if jvalue is TJSONString then
_field.SetValue(TObject(AObject), ISOStrToTime(jvalue.Value))
else
raise EMapperException.CreateFmt
('Cannot deserialize [%s], expected [%s] got [%s]',
[_field.Name, 'TJSONString', jvalue.ClassName]);
if not (jvalue is TJSONNull) then
if jvalue is TJSONString then
_field.SetValue(TObject(AObject), ISOStrToTime(jvalue.Value))
else
raise EMapperException.CreateFmt
('Cannot deserialize [%s], expected [%s] got [%s]',
[_field.Name, 'TJSONString', jvalue.ClassName]);
end
else { if _field.PropertyType.QualifiedName = 'System.Currency' then }
begin
if jvalue is TJSONNumber then
_field.SetValue(TObject(AObject), TJSONNumber(jvalue).AsDouble)
else
raise EMapperException.CreateFmt
('Cannot deserialize [%s], expected [%s] got [%s]',
[_field.Name, 'TJSONNumber', jvalue.ClassName]);
if not (jvalue is TJSONNull) then
if jvalue is TJSONNumber then
_field.SetValue(TObject(AObject), TJSONNumber(jvalue).AsDouble)
else
raise EMapperException.CreateFmt
('Cannot deserialize [%s], expected [%s] got [%s]',
[_field.Name, 'TJSONNumber', jvalue.ClassName]);
end {
else
begin