WriteJSON writes the provided struct v to w using standard json marshaling without a trailing newline. This is used instead of json.Encoder because there might be a problem in json decoder in some cases, see: https://github.com/docker/docker/issues/14203#issuecomment-174177790
(w io.Writer, v any)
| 27 | // there might be a problem in json decoder in some cases, see: |
| 28 | // https://github.com/docker/docker/issues/14203#issuecomment-174177790 |
| 29 | func WriteJSON(w io.Writer, v any) error { |
| 30 | data, err := json.Marshal(v) |
| 31 | if err != nil { |
| 32 | return err |
| 33 | } |
| 34 | _, err = w.Write(data) |
| 35 | return err |
| 36 | } |
| 37 | |
| 38 | // SearchLabels searches through a list of key=value pairs for a given key, |
| 39 | // returning its value, and the binary flag telling whether the key exist. |