2
0
Эх сурвалжийг харах

[jsonSerializer] support null as 0 for integer fields

Exilon 3 жил өмнө
parent
commit
9690168dfb

+ 10 - 6
Quick.Json.Serializer.pas

@@ -1,13 +1,13 @@
 { ***************************************************************************
 { ***************************************************************************
 
 
-  Copyright (c) 2015-2021 Kike Pérez
+  Copyright (c) 2015-2022 Kike Pérez
 
 
   Unit        : Quick.JSON.Serializer
   Unit        : Quick.JSON.Serializer
   Description : Json Serializer
   Description : Json Serializer
   Author      : Kike Pérez
   Author      : Kike Pérez
   Version     : 1.12
   Version     : 1.12
   Created     : 21/05/2018
   Created     : 21/05/2018
-  Modified    : 27/12/2021
+  Modified    : 26/01/2022
 
 
   This file is part of QuickLib: https://github.com/exilon/QuickLib
   This file is part of QuickLib: https://github.com/exilon/QuickLib
 
 
@@ -861,11 +861,13 @@ begin
         end;
         end;
       tkInteger :
       tkInteger :
         begin
         begin
-          Result := StrToInt(value);
+          if CompareText(value,'null') <> 0 then Result := StrToIntDef(value,0)
+            else Result := 0;
         end;
         end;
       tkInt64 :
       tkInt64 :
         begin
         begin
-          Result := StrToInt64(value);
+          if CompareText(value,'null') <> 0 then Result := StrToInt64Def(value,0)
+           else Result := 0;
         end;
         end;
       tkFloat :
       tkFloat :
         begin
         begin
@@ -947,11 +949,13 @@ begin
         end;
         end;
       tkInteger :
       tkInteger :
         begin
         begin
-          Result := StrToInt(value);
+          if CompareText(value,'null') <> 0 then Result := StrToInt(value)
+            else Result := 0;
         end;
         end;
       tkInt64 :
       tkInt64 :
         begin
         begin
-          Result := StrToInt64(value);
+          if CompareText(value,'null') <> 0 then Result := StrToInt64(value)
+            else Result := 0;
         end;
         end;
       tkFloat :
       tkFloat :
         begin
         begin