Explorar el Código

* FindValue more delphi-compatible in treatment of null

Michaël Van Canneyt hace 3 meses
padre
commit
8ab1fa256e
Se han modificado 1 ficheros con 3 adiciones y 2 borrados
  1. 3 2
      packages/vcl-compat/src/system.json.pp

+ 3 - 2
packages/vcl-compat/src/system.json.pp

@@ -1035,14 +1035,13 @@ var
 
 begin
   lValue:=FindValue(aPath);
-  Result:=Assigned(lValue);
+  Result:=Assigned(lValue) and not (lValue is TJSONNull);
   if Result then
     Try
       aValue:=lValue.specialize AsType<T>;
     except
       on E : Exception do
         begin
-        Writeln('Err',E.Message);
         Result:=False;
         end;
     end;
@@ -1067,6 +1066,8 @@ begin
   lValue:=FindValue(aPath);
   if not Assigned(lValue) then
     Result:=aDefaultValue
+  else if lValue is TJSONNull then
+    Result:=aDefaultValue
   else if not lValue.specialize TryGetValue<T>(Result) then
     Result:=aDefaultValue;
 end;