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

Method decode

pkg/util/json/encoded.go:522–543  ·  view source on GitHub ↗

decode should be used in cases where you will definitely have to use the entire decoded JSON structure, like printing it out to a string.

()

Source from the content-addressed store, hash-verified

520// decode should be used in cases where you will definitely have to use the
521// entire decoded JSON structure, like printing it out to a string.
522func (j *jsonEncoded) decode() (JSON, error) {
523 switch j.typ {
524 case NumberJSONType:
525 _, j, err := decodeJSONNumber(j.value)
526 return j, err
527 case StringJSONType:
528 return jsonString(j.value), nil
529 case TrueJSONType:
530 return TrueJSONValue, nil
531 case FalseJSONType:
532 return FalseJSONValue, nil
533 case NullJSONType:
534 return NullJSONValue, nil
535 }
536 _, decoded, err := DecodeJSON(j.value)
537
538 j.mu.Lock()
539 defer j.mu.Unlock()
540 j.mu.cachedDecoded = decoded
541
542 return decoded, err
543}
544
545func (j *jsonEncoded) AsText() (*string, error) {
546 if dec := j.alreadyDecoded(); dec != nil {

Callers 15

shallowDecodeMethod · 0.95
AsTextMethod · 0.95
AsDecimalMethod · 0.95
AsBoolMethod · 0.95
AsArrayMethod · 0.95
ExistsMethod · 0.95
EncodeForwardIndexMethod · 0.95
allPathsWithDepthMethod · 0.95

Calls 5

decodeJSONNumberFunction · 0.85
jsonStringTypeAlias · 0.85
DecodeJSONFunction · 0.85
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected