You've already forked json-iterator
mirror of
https://github.com/json-iterator/go.git
synced 2025-06-15 22:50:24 +02:00
fix marshaler support for iface case
This commit is contained in:
@ -1,19 +1,42 @@
|
||||
package test
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"encoding"
|
||||
)
|
||||
|
||||
func init() {
|
||||
jsonMarshaler := json.Marshaler(fakeJsonMarshaler{})
|
||||
textMarshaler := encoding.TextMarshaler(fakeTextMarshaler{})
|
||||
marshalCases = append(marshalCases,
|
||||
withChan{},
|
||||
fakeJsonMarshaler{},
|
||||
&jsonMarshaler,
|
||||
fakeTextMarshaler{},
|
||||
&textMarshaler,
|
||||
)
|
||||
}
|
||||
|
||||
type withChan struct {
|
||||
type fakeJsonMarshaler struct {
|
||||
F2 chan []byte
|
||||
}
|
||||
|
||||
func (q withChan) MarshalJSON() ([]byte, error) {
|
||||
func (q fakeJsonMarshaler) MarshalJSON() ([]byte, error) {
|
||||
return []byte(`""`), nil
|
||||
}
|
||||
|
||||
func (q *withChan) UnmarshalJSON(value []byte) error {
|
||||
func (q *fakeJsonMarshaler) UnmarshalJSON(value []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
type fakeTextMarshaler struct {
|
||||
F2 chan []byte
|
||||
}
|
||||
|
||||
func (q fakeTextMarshaler) MarshalText() ([]byte, error) {
|
||||
return []byte(`""`), nil
|
||||
}
|
||||
|
||||
func (q *fakeTextMarshaler) UnmarshalText(value []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user