فهرست منبع

[jsonSerializer] TDateTime 0.0 as null

Exilon 5 سال پیش
والد
کامیت
6c857edd51
1فایلهای تغییر یافته به همراه11 افزوده شده و 11 حذف شده
  1. 11 11
      Quick.Json.Serializer.pas

+ 11 - 11
Quick.Json.Serializer.pas

@@ -7,7 +7,7 @@
   Author      : Kike Pérez
   Author      : Kike Pérez
   Version     : 1.11
   Version     : 1.11
   Created     : 21/05/2018
   Created     : 21/05/2018
-  Modified    : 31/03/2020
+  Modified    : 05/04/2020
 
 
   This file is part of QuickLib: https://github.com/exilon/QuickLib
   This file is part of QuickLib: https://github.com/exilon/QuickLib
 
 
@@ -718,11 +718,11 @@ begin
         begin
         begin
           if aTypeInfo = TypeInfo(TDateTime) then
           if aTypeInfo = TypeInfo(TDateTime) then
           begin
           begin
-            Result := JsonDateToDateTime(value);
+            if CompareText(value,'null') <> 0 then Result := JsonDateToDateTime(value);
           end
           end
           else if aTypeInfo = TypeInfo(TDate) then
           else if aTypeInfo = TypeInfo(TDate) then
           begin
           begin
-            Result := StrToDate(value);
+            if CompareText(value,'null') <> 0 then Result := StrToDate(value);
           end
           end
           else if aTypeInfo = TypeInfo(TTime) then
           else if aTypeInfo = TypeInfo(TTime) then
           begin
           begin
@@ -804,11 +804,11 @@ begin
         begin
         begin
           if propinfo.PropType = TypeInfo(TDateTime) then
           if propinfo.PropType = TypeInfo(TDateTime) then
           begin
           begin
-            Result := JsonDateToDateTime(value);
+            if CompareText(value,'null') <> 0 then Result := JsonDateToDateTime(value);
           end
           end
           else if propinfo.PropType = TypeInfo(TDate) then
           else if propinfo.PropType = TypeInfo(TDate) then
           begin
           begin
-            Result := StrToDate(value);
+            if CompareText(value,'null') <> 0 then Result := StrToDate(value);
           end
           end
           else if propinfo.PropType = TypeInfo(TTime) then
           else if propinfo.PropType = TypeInfo(TTime) then
           begin
           begin
@@ -1218,11 +1218,11 @@ begin
         begin
         begin
           if aValue.TypeInfo = TypeInfo(TDateTime) then
           if aValue.TypeInfo = TypeInfo(TDateTime) then
           begin
           begin
-            Result.JsonValue := TJSONString.Create(DateTimeToJsonDate(aValue.AsExtended));
+            if aValue.AsExtended <> 0.0 then Result.JsonValue := TJSONString.Create(DateTimeToJsonDate(aValue.AsExtended));
           end
           end
           else if aValue.TypeInfo = TypeInfo(TDate) then
           else if aValue.TypeInfo = TypeInfo(TDate) then
           begin
           begin
-            Result.JsonValue := TJSONString.Create(DateToStr(aValue.AsExtended));
+            if aValue.AsExtended <> 0.0 then Result.JsonValue := TJSONString.Create(DateToStr(aValue.AsExtended));
           end
           end
           else if aValue.TypeInfo = TypeInfo(TTime) then
           else if aValue.TypeInfo = TypeInfo(TTime) then
           begin
           begin
@@ -1347,11 +1347,11 @@ begin
         begin
         begin
           if aValue.TypeInfo = TypeInfo(TDateTime) then
           if aValue.TypeInfo = TypeInfo(TDateTime) then
           begin
           begin
-            Result.JsonValue := TJSONString.Create(DateTimeToJsonDate(aValue.AsExtended));
+            if aValue.AsExtended <> 0.0 then Result.JsonValue := TJSONString.Create(DateTimeToJsonDate(aValue.AsExtended));
           end
           end
           else if aValue.TypeInfo = TypeInfo(TDate) then
           else if aValue.TypeInfo = TypeInfo(TDate) then
           begin
           begin
-            Result.JsonValue := TJSONString.Create(DateToStr(aValue.AsExtended));
+            if aValue.AsExtended <> 0.0 then Result.JsonValue := TJSONString.Create(DateToStr(aValue.AsExtended));
           end
           end
           else if aValue.TypeInfo = TypeInfo(TTime) then
           else if aValue.TypeInfo = TypeInfo(TTime) then
           begin
           begin
@@ -1463,11 +1463,11 @@ begin
         begin
         begin
           if propinfo.PropType = TypeInfo(TDateTime) then
           if propinfo.PropType = TypeInfo(TDateTime) then
           begin
           begin
-            Result.JsonValue := TJSONString.Create(DateTimeToJsonDate(GetFloatProp(aObject,aPropertyName)));
+            if aValue.AsExtended <> 0.0 then Result.JsonValue := TJSONString.Create(DateTimeToJsonDate(GetFloatProp(aObject,aPropertyName)));
           end
           end
           else if propinfo.PropType = TypeInfo(TDate) then
           else if propinfo.PropType = TypeInfo(TDate) then
           begin
           begin
-            Result.JsonValue := TJSONString.Create(DateToStr(GetFloatProp(aObject,aPropertyName)));
+            if aValue.AsExtended <> 0.0 then Result.JsonValue := TJSONString.Create(DateToStr(GetFloatProp(aObject,aPropertyName)));
           end
           end
           else if propinfo.PropType = TypeInfo(TTime) then
           else if propinfo.PropType = TypeInfo(TTime) then
           begin
           begin