mirror of
https://github.com/netbirdio/easyjson.git
synced 2026-05-22 18:44:42 -07:00
add test with nested marshaler interface
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package tests
|
||||
|
||||
import (
|
||||
"github.com/mailru/easyjson"
|
||||
"github.com/mailru/easyjson/jlexer"
|
||||
"github.com/mailru/easyjson/jwriter"
|
||||
)
|
||||
|
||||
type MarshalerUnmarshaler interface {
|
||||
easyjson.Marshaler
|
||||
easyjson.Unmarshaler
|
||||
}
|
||||
|
||||
//easyjson:json
|
||||
type NestedMarshaler struct {
|
||||
Value MarshalerUnmarshaler
|
||||
Value2 int
|
||||
}
|
||||
|
||||
type StructWithMarshaler struct {
|
||||
Value int
|
||||
}
|
||||
|
||||
func (s *StructWithMarshaler) UnmarshalEasyJSON(w *jlexer.Lexer) {
|
||||
s.Value = w.Int()
|
||||
}
|
||||
|
||||
func (s *StructWithMarshaler) MarshalEasyJSON(w *jwriter.Writer) {
|
||||
w.Int(s.Value)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user