diff --git a/types/convert/convert.go b/types/convert/convert.go index 43ba4774..a2a6c49a 100644 --- a/types/convert/convert.go +++ b/types/convert/convert.go @@ -104,7 +104,16 @@ func LowerTitle(input string) string { } func IsEmpty(v interface{}) bool { - return v == nil || v == "" || v == 0 || v == false + if v == nil || v == "" || v == 0 || v == false { + return true + } + if m, ok := v.(map[string]interface{}); ok { + return len(m) == 0 + } + if s, ok := v.([]interface{}); ok { + return len(s) == 0 + } + return false } func ToMapInterface(obj interface{}) map[string]interface{} { @@ -112,6 +121,13 @@ func ToMapInterface(obj interface{}) map[string]interface{} { return v } +func ToInterfaceSlice(obj interface{}) []interface{} { + if v, ok := obj.([]interface{}); ok { + return v + } + return nil +} + func ToMapSlice(obj interface{}) []map[string]interface{} { if v, ok := obj.([]map[string]interface{}); ok { return v