MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / formatEncodedJSON

Function formatEncodedJSON

pkg/util/json/encoded_format.go:55–77  ·  view source on GitHub ↗
(buf *bytes.Buffer, b []byte)

Source from the content-addressed store, hash-verified

53}
54
55func formatEncodedJSON(buf *bytes.Buffer, b []byte) ([]byte, error) {
56 b, containerHeader, err := encoding.DecodeUint32Ascending(b)
57 if err != nil {
58 return nil, err
59 }
60 switch containerHeader & containerHeaderTypeMask {
61 case scalarContainerTag:
62 var entry jEntry
63 var err error
64 b, entry, err = decodeJEntry(b, 0)
65 if err != nil {
66 return nil, err
67 }
68 return formatEncodedJSONValue(buf, entry, b)
69 case arrayContainerTag:
70 return formatEncodedJSONArray(buf, containerHeader, b)
71 case objectContainerTag:
72 return formatEncodedJSONObject(buf, containerHeader, b)
73 default:
74 return nil, errors.AssertionFailedf(
75 "error decoding JSON value, header: %x", errors.Safe(containerHeader))
76 }
77}
78
79func formatEncodedJSONArray(buf *bytes.Buffer, containerHeader uint32, b []byte) ([]byte, error) {
80 length := int(containerHeader & containerHeaderLenMask)

Callers 2

formatMethod · 0.85
formatEncodedJSONValueFunction · 0.85

Calls 5

DecodeUint32AscendingFunction · 0.92
decodeJEntryFunction · 0.85
formatEncodedJSONValueFunction · 0.85
formatEncodedJSONArrayFunction · 0.85
formatEncodedJSONObjectFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…