Skip to content

Commit

Permalink
update StructToJSONTagtringMap
Browse files Browse the repository at this point in the history
  • Loading branch information
xurwxj committed Jun 16, 2021
1 parent f70b74a commit a29245a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions base/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,19 @@ func StructToJSONTagtringMap(item interface{}) (res map[string]string) {
field := reflectValue.Field(i).String()
if v.Field(i).Type.Kind() == reflect.String {
res[tag] = field
} else if v.Field(i).Type.Kind() == reflect.Struct {
for t, tv := range StructToJSONTagtringMap(reflectValue.Field(i).Interface()) {
res[t] = tv
}
} else {
res = nil
continue
}
} else {
res = nil
if v.Field(i).Type.Kind() == reflect.Struct {
for t, tv := range StructToJSONTagtringMap(reflectValue.Field(i).Interface()) {
res[t] = tv
}
}
}
}
return
Expand Down

0 comments on commit a29245a

Please sign in to comment.