Skip to content

Commit

Permalink
[jsonSerializer] support null as 0 for integer fields
Browse files Browse the repository at this point in the history
  • Loading branch information
exilon committed Jan 26, 2022
1 parent 50815fd commit 9690168
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions Quick.Json.Serializer.pas
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{ ***************************************************************************
Copyright (c) 2015-2021 Kike Pérez
Copyright (c) 2015-2022 Kike Pérez
Unit : Quick.JSON.Serializer
Description : Json Serializer
Author : Kike Pérez
Version : 1.12
Created : 21/05/2018
Modified : 27/12/2021
Modified : 26/01/2022
This file is part of QuickLib: https://github.com/exilon/QuickLib
Expand Down Expand Up @@ -861,11 +861,13 @@ function TRTTIJson.DeserializeType(aObject : TObject; aType : TTypeKind; aTypeIn
end;
tkInteger :
begin
Result := StrToInt(value);
if CompareText(value,'null') <> 0 then Result := StrToIntDef(value,0)
else Result := 0;
end;
tkInt64 :
begin
Result := StrToInt64(value);
if CompareText(value,'null') <> 0 then Result := StrToInt64Def(value,0)
else Result := 0;
end;
tkFloat :
begin
Expand Down Expand Up @@ -947,11 +949,13 @@ function TRTTIJson.DeserializeType(aObject : TObject; aType : TTypeKind; const a
end;
tkInteger :
begin
Result := StrToInt(value);
if CompareText(value,'null') <> 0 then Result := StrToInt(value)
else Result := 0;
end;
tkInt64 :
begin
Result := StrToInt64(value);
if CompareText(value,'null') <> 0 then Result := StrToInt64(value)
else Result := 0;
end;
tkFloat :
begin
Expand Down

0 comments on commit 9690168

Please sign in to comment.