Skip to content

Commit

Permalink
更新
Browse files Browse the repository at this point in the history
  • Loading branch information
deatil committed Nov 29, 2022
1 parent 8b5ebfc commit c428423
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions array/array.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,17 @@ func (this Arr) anyMapFormat(data any) (map[any]any, bool) {
m := make(map[any]any)
isMap := false

dataKind := reflect.TypeOf(data).Kind()
if dataKind == reflect.Map {
iter := reflect.ValueOf(data).MapRange()
dataValue := reflect.ValueOf(data)
for dataValue.Kind() == reflect.Pointer {
dataValue = dataValue.Elem()
}

// 获取最后的数据
newData := dataValue.Interface()

newDataKind := reflect.TypeOf(newData).Kind()
if newDataKind == reflect.Map {
iter := reflect.ValueOf(newData).MapRange()
for iter.Next() {
k := iter.Key().Interface()
v := iter.Value().Interface()
Expand All @@ -288,13 +296,21 @@ func (this Arr) anySliceFormat(data any) ([]any, bool) {
m := make([]any, 0)
isSlice := false

dataKind := reflect.TypeOf(data).Kind()
if dataKind == reflect.Slice {
dataValue := reflect.ValueOf(data)
dataLen := dataValue.Len()
dataValue := reflect.ValueOf(data)
for dataValue.Kind() == reflect.Pointer {
dataValue = dataValue.Elem()
}

// 获取最后的数据
newData := dataValue.Interface()

newDataKind := reflect.TypeOf(newData).Kind()
if newDataKind == reflect.Slice {
newDataValue := reflect.ValueOf(newData)
newDataLen := newDataValue.Len()

for i := 0; i < dataLen; i++ {
v := dataValue.Index(i).Interface()
for i := 0; i < newDataLen; i++ {
v := newDataValue.Index(i).Interface()

m = append(m, v)
}
Expand Down

0 comments on commit c428423

Please sign in to comment.