MCPcopy
hub / github.com/cortexlabs/cortex / WriteJSON

Function WriteJSON

pkg/lib/json/json.go:69–82  ·  view source on GitHub ↗
(obj interface{}, outPath string)

Source from the content-addressed store, hash-verified

67}
68
69func WriteJSON(obj interface{}, outPath string) error {
70 jsonBytes, err := Marshal(obj)
71 if err != nil {
72 return err
73 }
74 if err := files.CreateDir(filepath.Dir(outPath)); err != nil {
75 return err
76 }
77
78 if err := files.WriteFile(jsonBytes, outPath); err != nil {
79 return err
80 }
81 return nil
82}
83
84func Pretty(obj interface{}) (string, error) {
85 b, err := json.MarshalIndent(obj, "", " ")

Callers

nothing calls this directly

Calls 3

CreateDirFunction · 0.92
WriteFileFunction · 0.92
MarshalFunction · 0.70

Tested by

no test coverage detected