瀏覽代碼

* FindValue more delphi-compatible in treatment of null

Michaël Van Canneyt 3 月之前
父節點
當前提交
8ab1fa256e
共有 1 個文件被更改,包括 3 次插入2 次删除
  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;