MCPcopy
hub / github.com/rs/zerolog / DecodeObjectToStr

Function DecodeObjectToStr

internal/cbor/decode_stream.go:636–643  ·  view source on GitHub ↗

DecodeObjectToStr checks if the input is a binary format, if so, it will decode a single Object and return the decoded string.

(in []byte)

Source from the content-addressed store, hash-verified

634// DecodeObjectToStr checks if the input is a binary format, if so,
635// it will decode a single Object and return the decoded string.
636func DecodeObjectToStr(in []byte) string {
637 if binaryFmt(in) {
638 var b bytes.Buffer
639 cbor2JsonOneObject(getReader(string(in)), &b)
640 return b.String()
641 }
642 return string(in)
643}
644
645// DecodeIfBinaryToBytes checks if the input is a binary format, if so,
646// it will decode all Objects and return the decoded string as byte array.

Callers 4

decodeObjectToStrFunction · 0.92
decodeOutputFunction · 0.92
decodeIfBinaryFunction · 0.92
TestDecodeObjectToStrFunction · 0.85

Calls 4

binaryFmtFunction · 0.85
cbor2JsonOneObjectFunction · 0.85
getReaderFunction · 0.85
StringMethod · 0.45

Tested by 3

decodeOutputFunction · 0.74
decodeIfBinaryFunction · 0.74
TestDecodeObjectToStrFunction · 0.68