Merge pull request #1284 from trheyi/main

Enhance getBool function to support multiple data types
This commit is contained in:
Max 2025-11-08 14:59:11 +08:00 committed by GitHub
commit 788b3d82c4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -9,8 +9,15 @@ func getString(data map[string]interface{}, key string) string {
} }
func getBool(data map[string]interface{}, key string) bool { func getBool(data map[string]interface{}, key string) bool {
if v, ok := data[key].(bool); ok { switch v := data[key].(type) {
case bool:
return v return v
case int64:
return v != 0
case int:
return v != 0
case float64:
return v != 0
} }
return false return false
} }