You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

unknown_fields.go 799B

1234567891011121314151617181920212223242526272829303132
  1. package easyjson
  2. import (
  3. jlexer "github.com/mailru/easyjson/jlexer"
  4. "github.com/mailru/easyjson/jwriter"
  5. )
  6. // UnknownFieldsProxy implemets UnknownsUnmarshaler and UnknownsMarshaler
  7. // use it as embedded field in your structure to parse and then serialize unknown struct fields
  8. type UnknownFieldsProxy struct {
  9. unknownFields map[string][]byte
  10. }
  11. func (s *UnknownFieldsProxy) UnmarshalUnknown(in *jlexer.Lexer, key string) {
  12. if s.unknownFields == nil {
  13. s.unknownFields = make(map[string][]byte, 1)
  14. }
  15. s.unknownFields[key] = in.Raw()
  16. }
  17. func (s UnknownFieldsProxy) MarshalUnknowns(out *jwriter.Writer, first bool) {
  18. for key, val := range s.unknownFields {
  19. if first {
  20. first = false
  21. } else {
  22. out.RawByte(',')
  23. }
  24. out.String(string(key))
  25. out.RawByte(':')
  26. out.Raw(val, nil)
  27. }
  28. }