mailru / easyjson

Fast JSON serializer for golang.
MIT License
4.48k stars 421 forks source link

Support Protocol Buffers #348

Open peterfajdiga opened 3 years ago

peterfajdiga commented 3 years ago

Easyjson does not work with structs generated by the Protocol Buffers go generator (protoc-gen-go).

The problem is that easyjson generates the MarshalEasyJSON method with a by-value receiver (introduced in https://github.com/mailru/easyjson/pull/15), but structs generated by protoc-gen-go shouldn't be copied.

Using a by-reference receiver should solve this issue.

FJSDS commented 3 years ago

use gogo protobuf.

peterfajdiga commented 3 years ago

@FJSDS Thanks for the suggestion, but gogo protobuf is not always a suitable alternative. It does not, for example, support optional fields in proto3.

bendiktv2 commented 3 years ago

+1.

It should hopefully marshal to the same as https://pkg.go.dev/google.golang.org/protobuf/encoding/protojson.