Merge pull request #51 from ezequieljuliano/master

Add validation for JSON Null time field conversion
This commit is contained in:
Daniele Teti 2016-09-06 16:18:11 +02:00 committed by GitHub
commit 75295f62bb
2 changed files with 15 additions and 13 deletions

@ -1 +1 @@
Subproject commit e6dc5e937038fcdc3c5e82033d66dea0775f4267
Subproject commit 31001af0cb56097b4a982d75c9089693a166863e

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