MCPcopy
hub / github.com/opencontainers/runc / WriteJSON

Function WriteJSON

libcontainer/utils/utils.go:29–36  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

27// there might be a problem in json decoder in some cases, see:
28// https://github.com/docker/docker/issues/14203#issuecomment-174177790
29func 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.

Callers 5

startMethod · 0.92
startMethod · 0.92
marshalFunction · 0.92
saveStateMethod · 0.92
TestWriteJSONFunction · 0.85

Calls 1

WriteMethod · 0.80

Tested by 2

marshalFunction · 0.74
TestWriteJSONFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…