MCPcopy Create free account
hub / github.com/pingcap/tidb / EncodeJSONCommon

Function EncodeJSONCommon

pkg/planner/util/debugtrace/base.go:112–122  ·  view source on GitHub ↗

EncodeJSONCommon contains some common logic for the debug trace, like disabling EscapeHTML and recording error.

(input any)

Source from the content-addressed store, hash-verified

110// EncodeJSONCommon contains some common logic for the debug trace,
111// like disabling EscapeHTML and recording error.
112func EncodeJSONCommon(input any) ([]byte, error) {
113 var buf bytes.Buffer
114 encoder := json.NewEncoder(&buf)
115 // If we do not set this to false, ">", "<", "&"... will be escaped to "\u003c","\u003e", "\u0026"...
116 encoder.SetEscapeHTML(false)
117 err := encoder.Encode(input)
118 if err != nil {
119 err = encoder.Encode(err)
120 }
121 return buf.Bytes(), err
122}
123
124// EnterContextCommon records the function name of the caller,
125// then creates and enter a new context for this debug trace structure.

Callers 4

MarshalJSONMethod · 0.92
MarshalJSONMethod · 0.92
MarshalJSONMethod · 0.85
MarshalJSONMethod · 0.85

Calls 3

EncodeMethod · 0.95
NewEncoderMethod · 0.65
BytesMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…