Yes... but in this case that would be in the generated protobuf code. Which would get over written anytime they are invoked. I guess I'm trying to find a place other that?? On Monday, November 15, 2021 at 5:56:54 PM UTC-6 Derek Perez wrote:
> I believe you can annotate the struct field using syntax similar to: > > status string `json:"statusCode"` > > for example. > > - D > > On Mon, Nov 15, 2021 at 3:52 PM Josh Morehead <[email protected]> > wrote: > >> I am wondering if there is a way to map a JSON field to a Go struct field >> of a different name?? >> >> For instance... can I put in my .proto an object with the field `status` >> and have that map to a JSON field of `statusCode`?? This way when I >> unmarshal the JSON the value at `statusCode` would appear in the Go struct >> field `status`. >> >> The only place I know to control that would be in the declaration of the >> struct housing the field... but in this case that is autogenerated code >> which appears to use the .proto field to create the mapped JSON field. Any >> help would be much appreciated. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Protocol Buffers" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/protobuf/80d8024a-90ce-4dda-9a27-8839e332096dn%40googlegroups.com >> >> <https://groups.google.com/d/msgid/protobuf/80d8024a-90ce-4dda-9a27-8839e332096dn%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > > On Mon, Nov 15, 2021 at 3:52 PM Josh Morehead <[email protected]> > wrote: > >> I am wondering if there is a way to map a JSON field to a Go struct field >> of a different name?? >> >> For instance... can I put in my .proto an object with the field `status` >> and have that map to a JSON field of `statusCode`?? This way when I >> unmarshal the JSON the value at `statusCode` would appear in the Go struct >> field `status`. >> >> The only place I know to control that would be in the declaration of the >> struct housing the field... but in this case that is autogenerated code >> which appears to use the .proto field to create the mapped JSON field. Any >> help would be much appreciated. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Protocol Buffers" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/protobuf/80d8024a-90ce-4dda-9a27-8839e332096dn%40googlegroups.com >> >> <https://groups.google.com/d/msgid/protobuf/80d8024a-90ce-4dda-9a27-8839e332096dn%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/a4af01ce-36d3-4556-b590-e84fc4bbb573n%40googlegroups.com.
