diff --git a/unknown_fields.go b/unknown_fields.go index 6cfdf83..55538ea 100644 --- a/unknown_fields.go +++ b/unknown_fields.go @@ -1,8 +1,6 @@ package easyjson import ( - json "encoding/json" - jlexer "github.com/mailru/easyjson/jlexer" "github.com/mailru/easyjson/jwriter" ) @@ -10,14 +8,14 @@ import ( // UnknownFieldsProxy implemets UnknownsUnmarshaler and UnknownsMarshaler // use it as embedded field in your structure to parse and then serialize unknown struct fields type UnknownFieldsProxy struct { - unknownFields map[string]interface{} + unknownFields map[string][]byte } func (s *UnknownFieldsProxy) UnmarshalUnknown(in *jlexer.Lexer, key string) { if s.unknownFields == nil { - s.unknownFields = make(map[string]interface{}, 1) + s.unknownFields = make(map[string][]byte, 1) } - s.unknownFields[key] = in.Interface() + s.unknownFields[key] = in.Raw() } func (s UnknownFieldsProxy) MarshalUnknowns(out *jwriter.Writer, first bool) { @@ -29,6 +27,6 @@ func (s UnknownFieldsProxy) MarshalUnknowns(out *jwriter.Writer, first bool) { } out.String(string(key)) out.RawByte(':') - out.Raw(json.Marshal(val)) + out.Raw(val, nil) } }