Merge pull request #1284 from trheyi/main
Enhance getBool function to support multiple data types
This commit is contained in:
commit
788b3d82c4
1 changed files with 8 additions and 1 deletions
|
|
@ -9,8 +9,15 @@ func getString(data map[string]interface{}, key string) string {
|
|||
}
|
||||
|
||||
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
|
||||
case int64:
|
||||
return v != 0
|
||||
case int:
|
||||
return v != 0
|
||||
case float64:
|
||||
return v != 0
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue