UnmarshalJSON satisfies json.Unmarshaler according to this type's documentation.
(b []byte)
| 164 | // UnmarshalJSON satisfies json.Unmarshaler according to |
| 165 | // this type's documentation. |
| 166 | func (ws *WeakString) UnmarshalJSON(b []byte) error { |
| 167 | if len(b) == 0 { |
| 168 | return io.EOF |
| 169 | } |
| 170 | if b[0] == byte('"') && b[len(b)-1] == byte('"') { |
| 171 | var s string |
| 172 | err := json.Unmarshal(b, &s) |
| 173 | if err != nil { |
| 174 | return err |
| 175 | } |
| 176 | *ws = WeakString(s) |
| 177 | return nil |
| 178 | } |
| 179 | if bytes.Equal(b, []byte("null")) { |
| 180 | return nil |
| 181 | } |
| 182 | *ws = WeakString(b) |
| 183 | return nil |
| 184 | } |
| 185 | |
| 186 | // MarshalJSON marshals was a boolean if true or false, |
| 187 | // a number if an integer, or a string otherwise. |
nothing calls this directly
no test coverage detected