Browse Source

* Merging revisions r46308 from trunk:
------------------------------------------------------------------------
r46308 | michael | 2020-08-07 16:07:59 +0200 (Fri, 07 Aug 2020) | 1 line

* Add jdoIgnoreNulls
------------------------------------------------------------------------

git-svn-id: branches/fixes_3_2@46614 -

michael 5 years ago
parent
commit
834ceb69b5
1 changed files with 4 additions and 2 deletions
  1. 4 2
      packages/fcl-json/src/fpjsonrtti.pp

+ 4 - 2
packages/fcl-json/src/fpjsonrtti.pp

@@ -113,7 +113,7 @@ Type
   TJSONRestorePropertyEvent = Procedure (Sender : TObject; AObject : TObject; Info : PPropInfo; AValue : TJSONData; Var Handled : Boolean) of object;
   TJSONRestorePropertyEvent = Procedure (Sender : TObject; AObject : TObject; Info : PPropInfo; AValue : TJSONData; Var Handled : Boolean) of object;
   TJSONPropertyErrorEvent = Procedure (Sender : TObject; AObject : TObject; Info : PPropInfo; AValue : TJSONData; Error : Exception; Var Continue : Boolean) of object;
   TJSONPropertyErrorEvent = Procedure (Sender : TObject; AObject : TObject; Info : PPropInfo; AValue : TJSONData; Error : Exception; Var Continue : Boolean) of object;
   TJSONGetObjectEvent = Procedure (Sender : TOBject; AObject : TObject; Info : PPropInfo; AData : TJSONObject; DataName : TJSONStringType; Var AValue : TObject);
   TJSONGetObjectEvent = Procedure (Sender : TOBject; AObject : TObject; Info : PPropInfo; AData : TJSONObject; DataName : TJSONStringType; Var AValue : TObject);
-  TJSONDestreamOption = (jdoCaseInsensitive,jdoIgnorePropertyErrors);
+  TJSONDestreamOption = (jdoCaseInsensitive,jdoIgnorePropertyErrors,jdoIgnoreNulls);
   TJSONDestreamOptions = set of TJSONDestreamOption;
   TJSONDestreamOptions = set of TJSONDestreamOption;
 
 
   TJSONDeStreamer = Class(TJSONFiler)
   TJSONDeStreamer = Class(TJSONFiler)
@@ -397,7 +397,9 @@ begin
       If B then
       If B then
         exit;
         exit;
       end;
       end;
-    DoRestoreProperty(AObject,PropInfo,PropData);
+    if (PropData.JSONType=jtNull) then
+      if Not (jdoIgnoreNulls in Options) then
+        DoRestoreProperty(AObject,PropInfo,PropData);
   except
   except
     On E : Exception do
     On E : Exception do
       If Assigned(FOnPropError) then
       If Assigned(FOnPropError) then