proto marshal to json enumber as string

默认情况下,将生成的pb struct marshal 后生成的json中,枚举值是整型。如何将枚举值编程string 呢用jsonpb,注意枚举值0 会被omitempty掉



https://github.com/golang/protobuf



var msg bytes.Buffer



m := jsonpb.Marshaler{}
err := m.Marshal(&msg, event)



https://stackoverflow.com/questions/49962893/converting-protobuf3-with-enum-to-json-in-go



https://pkg.go.dev/github.com/golang/protobuf/jsonpb#Marshaler.Marshal



https://github.com/golang/protobuf



https://seb-nyberg.medium.com/customizing-protobuf-json-serialization-in-golang-6c58b5890356



https://github.com/gogo/protobuf/blob/master/extensions.md



https://github.com/grpc-ecosystem/grpc-gateway/issues/1063



https://github.com/drslump/ProtoJson



https://github.com/protocolbuffers/protobuf-go



https://github.com/ludiosarchive/Protojson



Category golang