OK, have you tried setting this field option in your .proto file?
https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/descriptor.proto#L213

On Tue, Nov 16, 2021 at 10:06 AM Josh Morehead <[email protected]>
wrote:

> 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
> <https://groups.google.com/d/msgid/protobuf/a4af01ce-36d3-4556-b590-e84fc4bbb573n%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/CAJGs%2BiJ0EJZv7yxjmqxFTfO2K3%3DHXOmMG5pNKR557xP%3DC_DEaw%40mail.gmail.com.

Reply via email to