MCPcopy
hub / github.com/minio/minio-go / UnmarshalJSON

Method UnmarshalJSON

pkg/set/stringset.go:122–139  ·  view source on GitHub ↗

UnmarshalJSON - parses JSON data and creates new set with it.

(data []byte)

Source from the content-addressed store, hash-verified

120
121// UnmarshalJSON - parses JSON data and creates new set with it.
122func (set *StringSet) UnmarshalJSON(data []byte) error {
123 sl := []interface{}{}
124 var err error
125 if err = json.Unmarshal(data, &sl); err == nil {
126 *set = make(StringSet)
127 for _, s := range sl {
128 set.Add(fmt.Sprintf("%v", s))
129 }
130 } else {
131 var s interface{}
132 if err = json.Unmarshal(data, &s); err == nil {
133 *set = make(StringSet)
134 set.Add(fmt.Sprintf("%v", s))
135 }
136 }
137
138 return err
139}
140
141// String - returns printable string of the set.
142func (set StringSet) String() string {

Callers 1

Calls 1

AddMethod · 0.95

Tested by 1