Skip to content

Commit

Permalink
handle multiple json tag like omitempty
Browse files Browse the repository at this point in the history
  • Loading branch information
damoye committed Feb 2, 2018
1 parent 5f29f24 commit e3b0100
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions util.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package jsonmask

import (
"reflect"
"strings"
"sync"

"gopkg.in/oleiade/reflections.v1"
Expand Down Expand Up @@ -32,6 +33,11 @@ func getFiledNamesByJSONKeys(obj interface{}, jsonKeys []string) (map[string]str
}

for fieldName, key := range fieldTagMap {
keys := strings.Split(key, ",")
if len(keys) == 0 {
continue
}
key := keys[0]
for _, jsonKey := range jsonKeys {
if key == jsonKey {
fieldNames[jsonKey] = fieldName
Expand Down

0 comments on commit e3b0100

Please sign in to comment.