UnmarshalJSON - parses JSON data and creates new set with it.
(data []byte)
| 95 | |
| 96 | // UnmarshalJSON - parses JSON data and creates new set with it. |
| 97 | func (set *IntSet) UnmarshalJSON(data []byte) error { |
| 98 | sl := []int{} |
| 99 | var err error |
| 100 | if err = json.Unmarshal(data, &sl); err == nil { |
| 101 | *set = make(IntSet) |
| 102 | for _, i := range sl { |
| 103 | set.Add(i) |
| 104 | } |
| 105 | } |
| 106 | return err |
| 107 | } |
| 108 | |
| 109 | // String - returns printable string of the set. |
| 110 | func (set IntSet) String() string { |