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

Method decode

pkg/util/json/encoded.go:519–540  ·  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

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

Callers 10

shallowDecodeMethod · 0.95
AsTextMethod · 0.95
ExistsMethod · 0.95
FormatMethod · 0.95
allPathsMethod · 0.95
HasContainerLeafMethod · 0.95
preprocessForContainsMethod · 0.95
decodeIfNeededFunction · 0.80

Calls 5

decodeJSONNumberFunction · 0.85
jsonStringTypeAlias · 0.85
DecodeJSONFunction · 0.85
LockMethod · 0.80
UnlockMethod · 0.80

Tested by

no test coverage detected