1
0
mirror of https://github.com/json-iterator/go.git synced 2025-10-31 00:07:40 +02:00

#63 fix Marshaler and Unmarshaler on struct

This commit is contained in:
Tao Wen
2017-06-20 07:23:22 +08:00
parent f5edf564c8
commit 839247df05
2 changed files with 29 additions and 2 deletions

View File

@@ -213,3 +213,22 @@ func Test_unmarshaler_and_decoder(t *testing.T) {
should.Nil(err)
should.Equal(10, int(*obj.Field))
}
type tmString string
type tmStruct struct {
String tmString
}
func (s tmStruct) MarshalJSON() ([]byte, error) {
var b []byte
b = append(b, '"')
b = append(b, s.String...)
b = append(b, '"')
return b, nil
}
func Test_marshaler_on_struct(t *testing.T) {
fixed := tmStruct{"hello"}
//json.Marshal(fixed)
Marshal(fixed)
}