AppendEmbeddedJSON adds a tag and embeds input JSON as such.
(dst, s []byte)
| 73 | |
| 74 | // AppendEmbeddedJSON adds a tag and embeds input JSON as such. |
| 75 | func 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. |
| 98 | func AppendEmbeddedCBOR(dst, s []byte) []byte { |