diff --git a/zjson/get.go b/zjson/get.go index 1487682..29f25d1 100644 --- a/zjson/get.go +++ b/zjson/get.go @@ -1983,15 +1983,21 @@ func assign(jsval *Res, val reflect.Value, fmap *fieldMaps) { key := t.Key() s := key.Kind() == reflect.String if s { - v := reflect.MakeMap(t) - jsval.ForEach(func(key, value *Res) bool { - newval := reflect.New(t.Elem()) - elem := newval.Elem() - assign(value, elem, fmap) - v.SetMapIndex(zreflect.ValueOf(key.Value()), elem) - return true - }) - val.Set(v) + kind := t.Elem().Kind() + switch kind { + case reflect.Interface: + val.Set(zreflect.ValueOf(jsval.Value())) + case reflect.Struct, reflect.Ptr: + v := reflect.MakeMap(t) + jsval.ForEach(func(key, value *Res) bool { + newval := reflect.New(t.Elem()) + elem := newval.Elem() + assign(value, elem, fmap) + v.SetMapIndex(zreflect.ValueOf(key.Value()), elem) + return true + }) + val.Set(v) + } } case reflect.Interface: val.Set(zreflect.ValueOf(jsval.Value())) diff --git a/zstring/snowflake.go b/zstring/snowflake.go index a37f67f..a29dae3 100644 --- a/zstring/snowflake.go +++ b/zstring/snowflake.go @@ -55,7 +55,6 @@ func (iw *IDWorker) timeGen() int64 { func (iw *IDWorker) timeReGen(last int64) int64 { ts := iw.timeGen() - println(ts, last, last-ts) for { if ts < last { ts = iw.timeGen() diff --git a/ztype/slice.go b/ztype/slice.go index 0c0405d..043d303 100644 --- a/ztype/slice.go +++ b/ztype/slice.go @@ -126,6 +126,8 @@ func ToSlice(value interface{}, noConv ...bool) (s SliceType) { return } s = SliceType{New(val)} + case Type: + return ToSlice(val.Value()) default: var nval []interface{} vof := zreflect.ValueOf(&nval)