jhump / protoreflect

Reflection (Rich Descriptors) for Go Protocol Buffers
Apache License 2.0
1.35k stars 172 forks source link

Is there a way to UseProtoNames? #616

Closed renier closed 4 months ago

renier commented 4 months ago

I'm missing the option to using the proto field names for the resulting json keys, similar to what the protojson package allows with its UseProtoNames option. https://pkg.go.dev/google.golang.org/protobuf/encoding/protojson#MarshalOptions

jhump commented 4 months ago

@renier, I assume you are referring to the JSON support provided by *dynamic.Message?

I would recommend instead using the dynamic message implementation in the Protobuf Go runtime: google.golang.org/protobuf/types/dynamicpb.

My implementation pre-dates theirs. But now that there exists an implementation in the standard runtime, I strongly encourage using it. Because my implementation was based on the older v1 of the Protobuf API, it has numerous limitations, and I am not planning to invest any time in improving it. (The v1 API is what's in github.com/golang/protobuf; the "v2" API is in google.golang.org/protobuf.)

renier commented 4 months ago

@jhump Yes, that's what I was referring to. Thanks for the explanation. I arrived here because I was trying out proton (https://github.com/beatlabs/proton) which uses this implementation of dynamic. It would make more sense of that tool updated to use dynamicpb as you suggest.