MCPcopy Create free account
hub / github.com/brimdata/super / MarshalJSONFile

Function MarshalJSONFile

pkg/fs/jsonfile.go:13–19  ·  view source on GitHub ↗

MarshalJSONFile writes the JSON encoding of v to a file named by filename. The file is created atomically. If the file does not exist, Marshal creates it with permissions perm.

(v any, filename string, perm os.FileMode)

Source from the content-addressed store, hash-verified

11// The file is created atomically. If the file does not exist, Marshal creates
12// it with permissions perm.
13func MarshalJSONFile(v any, filename string, perm os.FileMode) (err error) {
14 return ReplaceFile(filename, perm, func(w io.Writer) error {
15 e := json.NewEncoder(w)
16 e.SetIndent("", " ")
17 return e.Encode(v)
18 })
19}
20
21// UnmarshalJSONFile parses JSON-encoded data from the file named by filename
22// and stores the result in the value pointed to by v. Internally, Unmarshal

Callers

nothing calls this directly

Calls 2

EncodeMethod · 0.95
ReplaceFileFunction · 0.85

Tested by

no test coverage detected