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

Function cbor2JsonOneObject

internal/cbor/decode_stream.go:539–575  ·  view source on GitHub ↗
(src *bufio.Reader, dst io.Writer)

Source from the content-addressed store, hash-verified

537}
538
539func cbor2JsonOneObject(src *bufio.Reader, dst io.Writer) {
540 pb, e := src.Peek(1)
541 if e != nil {
542 panic(e)
543 }
544 major := (pb[0] & maskOutAdditionalType)
545
546 switch major {
547 case majorTypeUnsignedInt:
548 fallthrough
549 case majorTypeNegativeInt:
550 n := decodeInteger(src)
551 dst.Write([]byte(strconv.Itoa(int(n))))
552
553 case majorTypeByteString:
554 s := decodeString(src, false)
555 dst.Write(s)
556
557 case majorTypeUtf8String:
558 s := decodeUTF8String(src)
559 dst.Write(s)
560
561 case majorTypeArray:
562 array2Json(src, dst)
563
564 case majorTypeMap:
565 map2Json(src, dst)
566
567 case majorTypeTags:
568 s := decodeTagData(src)
569 dst.Write(s)
570
571 case majorTypeSimpleAndFloat:
572 s := decodeSimpleFloat(src)
573 dst.Write(s)
574 }
575}
576
577func moreBytesToRead(src *bufio.Reader) bool {
578 _, e := src.ReadByte()

Callers 4

array2JsonFunction · 0.85
map2JsonFunction · 0.85
Cbor2JsonManyObjectsFunction · 0.85
DecodeObjectToStrFunction · 0.85

Calls 8

decodeIntegerFunction · 0.85
decodeStringFunction · 0.85
decodeUTF8StringFunction · 0.85
array2JsonFunction · 0.85
map2JsonFunction · 0.85
decodeTagDataFunction · 0.85
decodeSimpleFloatFunction · 0.85
WriteMethod · 0.45

Tested by

no test coverage detected