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

Function AppendEmbeddedJSON

internal/cbor/string.go:75–95  ·  view source on GitHub ↗

AppendEmbeddedJSON adds a tag and embeds input JSON as such.

(dst, s []byte)

Source from the content-addressed store, hash-verified

73
74// AppendEmbeddedJSON adds a tag and embeds input JSON as such.
75func AppendEmbeddedJSON(dst, s []byte) []byte {
76 major := majorTypeTags
77 minor := additionalTypeEmbeddedJSON
78
79 // Append the TAG to indicate this is Embedded JSON.
80 dst = append(dst, major|additionalTypeIntUint16)
81 dst = append(dst, byte(minor>>8))
82 dst = append(dst, byte(minor&0xff))
83
84 // Append the JSON Object as Byte String.
85 major = majorTypeByteString
86
87 l := len(s)
88 if l <= additionalMax {
89 lb := byte(l)
90 dst = append(dst, major|lb)
91 } else {
92 dst = appendCborTypePrefix(dst, major, uint64(l))
93 }
94 return append(dst, s...)
95}
96
97// AppendEmbeddedCBOR adds a tag and embeds input CBOR as such.
98func AppendEmbeddedCBOR(dst, s []byte) []byte {

Callers 3

appendJSONFunction · 0.92
TestAppendEmbeddedJSONFunction · 0.85
AppendInterfaceMethod · 0.85

Calls 1

appendCborTypePrefixFunction · 0.85

Tested by 1

TestAppendEmbeddedJSONFunction · 0.68