* Merging revisions r46328 from trunk:

------------------------------------------------------------------------
    r46328 | michael | 2020-08-08 14:28:19 +0200 (Sat, 08 Aug 2020) | 1 line
    
    * Add testcase for jdoIgnoreNulls
    ------------------------------------------------------------------------

git-svn-id: branches/fixes_3_2@46636 -
This commit is contained in:
michael 2020-08-23 10:23:10 +00:00
parent 9f9276f01c
commit 3d7a00bfc9
2 changed files with 31 additions and 3 deletions

View File

@ -398,9 +398,8 @@ begin
If B then
exit;
end;
if (PropData.JSONType=jtNull) then
if Not (jdoIgnoreNulls in Options) then
DoRestoreProperty(AObject,PropInfo,PropData);
if (PropData.JSONType<>jtNull) or not (jdoIgnoreNulls in Options) then
DoRestoreProperty(AObject,PropInfo,PropData)
except
On E : Exception do
If Assigned(FOnPropError) then

View File

@ -122,6 +122,7 @@ type
procedure DeStream(JSON: TJSONStringType; AObject: TObject);
procedure DeStream(JSON: TJSONObject; AObject: TObject);
procedure DoDateTimeFormat;
Procedure DoNullError;
protected
procedure SetUp; override;
procedure TearDown; override;
@ -138,6 +139,8 @@ type
Procedure TestVariantString;
Procedure TestVariantArray;
procedure TestEmpty;
procedure TestNullError;
procedure TestNull;
procedure TestBoolean;
procedure TestInteger;
procedure TestIntegerCaseInsensitive;
@ -284,6 +287,23 @@ begin
AssertEquals('Empty Tag',0,TComponent(FToFree).Tag);
end;
procedure TTestJSONDeStreamer.TestNullError;
begin
AssertException('Null error',EJSON, @DoNullError);
end;
procedure TTestJSONDeStreamer.TestNull;
Var
B : TBooleanComponent;
begin
B:=TBooleanComponent.Create(Nil);
DS.Options:=DS.Options+[jdoIgnoreNulls];
DeStream('{ "BooleanProp" : null }',B);
AssertEquals('Correct boolean value',False,B.BooleanProp);
end;
procedure TTestJSONDeStreamer.DeStream(JSON : TJSONStringType; AObject : TObject);
begin
@ -428,6 +448,15 @@ begin
DeStream('{"DateTimeProp" : "'+DateTimeToStr(RecodeMillisecond(Now,0))+'"}',FToFree);
end;
procedure TTestJSONDeStreamer.DoNullError;
Var
B : TBooleanComponent;
begin
B:=TBooleanComponent.Create(Nil);
Destream('{ "BooleanProp" : null }',B);
end;
procedure TTestJSONDeStreamer.TestDateTimeFormat;
Const