Skip to content

Commit

Permalink
Merge pull request #2 from damoye/master
Browse files Browse the repository at this point in the history
feat: handle multiple json tag like omitempty
  • Loading branch information
David Cai authored Feb 3, 2018
2 parents 5f29f24 + e3b0100 commit de5ce4e
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 de5ce4e

Please sign in to comment.