MCPcopy Create free account
hub / github.com/coder/aibridge / prettyPrintJSON

Function prettyPrintJSON

intercept/apidump/apidump.go:264–275  ·  view source on GitHub ↗

prettyPrintJSON returns indented JSON if body is valid JSON, otherwise returns body as-is. Unlike json.MarshalIndent, this preserves the original key order from the input, which makes the dumps easier to read and compare with the original requests.

(body []byte)

Source from the content-addressed store, hash-verified

262// Unlike json.MarshalIndent, this preserves the original key order from the input,
263// which makes the dumps easier to read and compare with the original requests.
264func prettyPrintJSON(body []byte) []byte {
265 if len(body) == 0 {
266 return body
267 }
268
269 result := body
270 if json.Valid(body) {
271 result = pretty.Pretty(body)
272 }
273
274 return result
275}

Callers 2

TestPrettyPrintJSONFunction · 0.85
dumpRequestMethod · 0.85

Calls

no outgoing calls

Tested by 1

TestPrettyPrintJSONFunction · 0.68