mirror of
https://github.com/netbirdio/easyjson.git
synced 2026-05-22 18:44:42 -07:00
optimize deafult UnknownFieldsProxy realisations with []byte in place of interface{}
This commit is contained in:
+4
-6
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user