UnmarshalJSON implements [json.Unmarshaler] and loads the provided json data into the current FieldsList.
(data []byte)
| 316 | // UnmarshalJSON implements [json.Unmarshaler] and |
| 317 | // loads the provided json data into the current FieldsList. |
| 318 | func (l *FieldsList) UnmarshalJSON(data []byte) error { |
| 319 | fwts := []fieldWithType{} |
| 320 | |
| 321 | if err := json.Unmarshal(data, &fwts); err != nil { |
| 322 | return err |
| 323 | } |
| 324 | |
| 325 | *l = []Field{} // reset |
| 326 | |
| 327 | for _, fwt := range fwts { |
| 328 | l.add(-1, fwt.Field) |
| 329 | } |
| 330 | |
| 331 | return nil |
| 332 | } |
| 333 | |
| 334 | // MarshalJSON implements the [json.Marshaler] interface. |
| 335 | func (l FieldsList) MarshalJSON() ([]byte, error) { |