浏览代码

* Patch from Luiz Americo to return a variant with get

git-svn-id: trunk@21821 -
michael 13 年之前
父节点
当前提交
3d002a13c5
共有 1 个文件被更改,包括 13 次插入0 次删除
  1. 13 0
      packages/fcl-json/src/fpjson.pp

+ 13 - 0
packages/fcl-json/src/fpjson.pp

@@ -396,6 +396,7 @@ Type
     Function IndexOfName(const AName: TJSONStringType; CaseInsensitive : Boolean = False): Integer;
     Function Find(Const AName : String) : TJSONData; overload;
     Function Find(Const AName : String; AType : TJSONType) : TJSONData; overload;
+    Function Get(Const AName : String) : Variant;
     Function Get(Const AName : String; ADefault : TJSONFloat) : TJSONFloat;
     Function Get(Const AName : String; ADefault : Integer) : Integer;
     Function Get(Const AName : String; ADefault : Int64) : Int64;
@@ -2059,6 +2060,18 @@ begin
     Result:=Nil
 end;
 
+function TJSONObject.Get(const AName: String): Variant;
+Var
+  I : Integer;
+
+begin
+  I:=IndexOfName(AName);
+  If (I<>-1) then
+    Result:=Items[i].Value
+  else
+    Result:=Null;
+end;
+
 function TJSONObject.Get(const AName: String; ADefault: TJSONFloat
   ): TJSONFloat;