mirror of
https://github.com/cwinfo/matterbridge.git
synced 2024-12-27 22:35:43 +00:00
2f33fe86f5
* Update dependencies and build to go1.22 * Fix api changes wrt to dependencies * Update golangci config
52 lines
996 B
Go
52 lines
996 B
Go
// +build !binary_log
|
|
|
|
package zerolog
|
|
|
|
// encoder_json.go file contains bindings to generate
|
|
// JSON encoded byte stream.
|
|
|
|
import (
|
|
"encoding/base64"
|
|
"github.com/rs/zerolog/internal/json"
|
|
)
|
|
|
|
var (
|
|
_ encoder = (*json.Encoder)(nil)
|
|
|
|
enc = json.Encoder{}
|
|
)
|
|
|
|
func init() {
|
|
// using closure to reflect the changes at runtime.
|
|
json.JSONMarshalFunc = func(v interface{}) ([]byte, error) {
|
|
return InterfaceMarshalFunc(v)
|
|
}
|
|
}
|
|
|
|
func appendJSON(dst []byte, j []byte) []byte {
|
|
return append(dst, j...)
|
|
}
|
|
func appendCBOR(dst []byte, cbor []byte) []byte {
|
|
dst = append(dst, []byte("\"data:application/cbor;base64,")...)
|
|
l := len(dst)
|
|
enc := base64.StdEncoding
|
|
n := enc.EncodedLen(len(cbor))
|
|
for i := 0; i < n; i++ {
|
|
dst = append(dst, '.')
|
|
}
|
|
enc.Encode(dst[l:], cbor)
|
|
return append(dst, '"')
|
|
}
|
|
|
|
func decodeIfBinaryToString(in []byte) string {
|
|
return string(in)
|
|
}
|
|
|
|
func decodeObjectToStr(in []byte) string {
|
|
return string(in)
|
|
}
|
|
|
|
func decodeIfBinaryToBytes(in []byte) []byte {
|
|
return in
|
|
}
|