Wrong google/uuid serialization
Opened this issue · 0 comments
prochac commented
ffjson generates wrong marshaler for github/google/uuid#UUID type
It implements fmt.Stringer
, encoding.BinaryMarshaler
and encoding.TextMarshaler
.
Insead of expected
{"Bar":"0eec3f57-eb61-4833-a78e-fdf6eb8ac4ae"}
I get
{"Bar":[14,236,63,87,235,97,72,51,167,142,253,246,235,138,196,174]}
main.go
package ffjson_uuid
import "github.com/google/uuid"
//go:generate ffjson main.go
type Foo struct {
Bar uuid.UUID
}
main_ffjson.go
...
// MarshalJSONBuf marshal buff to json - template
func (j *Foo) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
if j == nil {
buf.WriteString("null")
return nil
}
var err error
var obj []byte
_ = obj
_ = err
buf.WriteString(`{"Bar":`)
buf.WriteString(`[`)
for i, v := range j.Bar {
if i != 0 {
buf.WriteString(`,`)
}
fflib.FormatBits2(buf, uint64(v), 10, false)
}
buf.WriteString(`]`)
buf.WriteByte('}')
return nil
}
...