0x4a52466c696e74 8 months ago
parent
commit
0856f1c407
1 changed files with 12 additions and 0 deletions
  1. 12 0
      json/map.go

+ 12 - 0
json/map.go

@@ -11,6 +11,18 @@ import (
 // Map type
 type Map map[string]interface{}
 
+func IsMap(val any) (res Map, check bool) {
+	switch tv := val.(type) {
+	case map[string]any:
+		res, check = Map(tv), true
+	case Map:
+		res, check = tv, true
+	default:
+		res = nil
+	}
+	return
+}
+
 // New init Map object
 func NewMap() Map {
 	return make(Map)