Quellcode durchsuchen

Fixed GetReal & added GetBool

thareh vor 2 Jahren
Ursprung
Commit
e6c9eab175
1 geänderte Dateien mit 12 neuen und 1 gelöschten Zeilen
  1. 12 1
      json.mod/json.bmx

+ 12 - 1
json.mod/json.bmx

@@ -480,11 +480,22 @@ Type TJSONObject Extends TJSON
 	returns: Null if key is not found, the value is not a Real, or on error.
 	End Rem
 	Method GetReal:Double(key:String)
-		Local r:TJSONInteger = TJSONInteger(bmx_json_object_get(jsonPtr, key))
+		Local r:TJSONReal = TJSONReal(bmx_json_object_get(jsonPtr, key))
 		If r Then
 			Return r.Value()
 		End If
 	End Method
+	
+	Rem
+	bbdoc: Gets a Boolean value corresponding to key from the object.
+	returns: Null if key is not found, the value is not a Boolean, or on error.
+	End Rem
+	Method GetBool:Int(key:String)
+		Local b:TJSONBool = TJSONBool(bmx_json_object_get(jsonPtr, key))
+		If b Then
+			Return b.isTrue
+		End If
+	End Method
 
 End Type