0x4a52466c696e74 8 月之前
父节点
当前提交
0856f1c407
共有 1 个文件被更改,包括 12 次插入0 次删除
  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)