support create map instance
diff --git a/map.go b/map.go
index e7ac6ff..dc74493 100644
--- a/map.go
+++ b/map.go
@@ -266,8 +266,8 @@
if !ok {
return nil, perrors.Errorf("the type of map key must be string, but get %v", k)
}
- if instValue.Elem().Kind() == reflect.Map {
- instValue.Elem().SetMapIndex(reflect.ValueOf(k), EnsureRawValue(v))
+ if instValue.Kind() == reflect.Map {
+ instValue.SetMapIndex(reflect.ValueOf(k), EnsureRawValue(v))
} else {
fieldValue = instValue.FieldByName(fieldName)
if fieldValue.IsValid() {
diff --git a/pojo.go b/pojo.go
index ad34bc9..792c226 100644
--- a/pojo.go
+++ b/pojo.go
@@ -388,6 +388,10 @@
return nil
}
+ if s.typ.Kind() == reflect.Map {
+ return reflect.MakeMap(s.typ).Interface()
+ }
+
return reflect.New(s.typ).Interface()
}