From 8edd6241e6344c40d938e75fc1c9efc5ddf6cf74 Mon Sep 17 00:00:00 2001 From: "joao.duarte" Date: Thu, 10 Jan 2019 14:30:40 -0200 Subject: [PATCH] Bug fix when deserialize object with custom type and JSON with null value --- sources/MVCFramework.Serializer.JsonDataObjects.pas | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sources/MVCFramework.Serializer.JsonDataObjects.pas b/sources/MVCFramework.Serializer.JsonDataObjects.pas index c82a7365..4391917d 100644 --- a/sources/MVCFramework.Serializer.JsonDataObjects.pas +++ b/sources/MVCFramework.Serializer.JsonDataObjects.pas @@ -531,8 +531,12 @@ begin jdtNone: Exit; jdtObject: - GetTypeSerializers.Items[AValue.TypeInfo].DeserializeAttribute(AValue, AName, AJsonObject[AName].ObjectValue, - ACustomAttributes); + begin + /// JsonDataObjects assumes values null as jdtObject + if AJsonObject[AName].ObjectValue <> nil then + GetTypeSerializers.Items[AValue.TypeInfo].DeserializeAttribute(AValue, AName, AJsonObject[AName].ObjectValue, + ACustomAttributes); + end; jdtArray: GetTypeSerializers.Items[AValue.TypeInfo].DeserializeAttribute(AValue, AName, AJsonObject[AName].ArrayValue, ACustomAttributes);