easyjson icon indicating copy to clipboard operation
easyjson copied to clipboard

Support Protocol Buffers

Open peterfajdiga opened this issue 4 years ago • 3 comments

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.

peterfajdiga avatar Aug 24 '21 14:08 peterfajdiga

use gogo protobuf.

FJSDS avatar Aug 30 '21 07:08 FJSDS

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

peterfajdiga avatar Sep 01 '21 08:09 peterfajdiga

+1.

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

bendiktv2 avatar Sep 24 '21 06:09 bendiktv2