MCPcopy Index your code
hub / github.com/jetify-com/devbox / MarshalJSON

Function MarshalJSON

internal/cuecfg/json.go:21–30  ·  view source on GitHub ↗

MarshalJSON marshals the given value to JSON. It does not HTML escape and adds standard indentation. TODO: consider using cue's JSON marshaller instead of "encoding/json" ... it might have extra functionality related to the cue language.

(v interface{})

Source from the content-addressed store, hash-verified

19// "encoding/json" ... it might have extra functionality related
20// to the cue language.
21func MarshalJSON(v interface{}) ([]byte, error) {
22 buff := &bytes.Buffer{}
23 e := json.NewEncoder(buff)
24 e.SetIndent("", Indent)
25 e.SetEscapeHTML(false)
26 if err := e.Encode(v); err != nil {
27 return nil, errors.WithStack(err)
28 }
29 return bytes.TrimRight(buff.Bytes(), "\n"), nil
30}
31
32func unmarshalJSON(data []byte, v interface{}) error {
33 return json.Unmarshal(data, v)

Callers 6

toJSONFunction · 0.92
MarshalJSONMethod · 0.92
MarshalFunction · 0.85

Calls 1

BytesMethod · 0.80

Tested by 2