diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/common.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/common.go b/lib/common.go index 51fd6b24..ed7c2e02 100644 --- a/lib/common.go +++ b/lib/common.go @@ -1,6 +1,7 @@ package lib import ( + "encoding/json" "fmt" "io" "net/http" @@ -32,3 +33,30 @@ func GetRemoteURLReader(url string) (io.ReadCloser, error) { return resp.Body, nil } + +type WantedListExtended struct { + TypeSlice []string + TypeMap map[string][]string +} + +func (w *WantedListExtended) UnmarshalJSON(data []byte) error { + if len(data) == 0 { + return nil + } + + slice := make([]string, 0) + mapMap := make(map[string][]string, 0) + + err := json.Unmarshal(data, &slice) + if err != nil { + err2 := json.Unmarshal(data, &mapMap) + if err2 != nil { + return err2 + } + } + + w.TypeSlice = slice + w.TypeMap = mapMap + + return nil +} |
