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

Function formatEncodedJSONValue

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

Source from the content-addressed store, hash-verified

188}
189
190func formatEncodedJSONValue(buf *bytes.Buffer, e jEntry, b []byte) ([]byte, error) {
191 switch e.typCode {
192 case trueTag:
193 TrueJSONValue.Format(buf)
194 case falseTag:
195 FalseJSONValue.Format(buf)
196 case nullTag:
197 NullJSONValue.Format(buf)
198 case stringTag:
199 s := unsafeJSONString(b[:e.length])
200 s.Format(buf)
201 b = b[e.length:]
202 case numberTag:
203 var d jsonNumber
204 var err error
205 b, d, err = decodeJSONNumber(b)
206 if err != nil {
207 return nil, err
208 }
209 d.Format(buf)
210 case containerTag:
211 return formatEncodedJSON(buf, b)
212 default:
213 return nil, errors.AssertionFailedf(
214 "error decoding JSON value, unexpected type code: %d", errors.Safe(e.typCode))
215 }
216 return b, nil
217}
218
219func unsafeJSONString(b []byte) jsonString {
220 return jsonString(encoding.UnsafeConvertBytesToString(b))

Callers 3

formatEncodedJSONFunction · 0.85
formatEncodedJSONArrayFunction · 0.85
formatEncodedJSONObjectFunction · 0.85

Calls 5

FormatMethod · 0.95
unsafeJSONStringFunction · 0.85
decodeJSONNumberFunction · 0.85
formatEncodedJSONFunction · 0.85
FormatMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…