So as I've gotten deeper this functionality does not do what I need sadly.

Which puts me back a square one... hoping to find something in the protobuf 
ability that allows me to alter the "json" section of the following code 
generated by the protoc command.

Status string  `protobuf:"bytes,15,opt,name=status,proto3" 
json:"status,omitempty"`

If I could figure out how to get protoc to generate say statusCode while 
setting my gRPC object to still have Status. Hopefully that clears up any 
confusion from the thread thus far.

On Monday, November 22, 2021 at 9:15:19 AM UTC-7 Josh Morehead wrote:

> Derek,
>
> Hard to say. This functionality feels overly complicated to me.
> I'm surprised there hasn't been an obvious and easy fix for something like 
> this honestly.
>
> Still poking at things with no luck thus far.
>
> On Friday, November 19, 2021 at 10:08:42 AM UTC-7 Derek Perez wrote:
>
>> Perhaps this is related? https://github.com/golang/protobuf/issues/189
>>
>> On Fri, Nov 19, 2021 at 8:57 AM Josh Morehead <[email protected]> 
>> wrote:
>>
>>> Derek,
>>>
>>> It's actually doing nothing at this point. I added that tag and it 
>>> changed nothing. The hope was that the tag would make it so that the 
>>> ""statusCode field on the incoming JSON would map to the "status" field on 
>>> my internal gRPC object.
>>> On Friday, November 19, 2021 at 9:53:12 AM UTC-7 Derek Perez wrote:
>>>
>>>> Can you describe what you're seeing? I am not sure what it means to not 
>>>> work.
>>>>
>>>> On Fri, Nov 19, 2021 at 8:52 AM Josh Morehead <[email protected]> 
>>>> wrote:
>>>>
>>>>> Hey all... Finally got to test this out. So far it's not working. 
>>>>> Trying to dig in deeper to see if there's something I'm missing. Not much 
>>>>> on this out there sadly.
>>>>> Thus far I've tried the below:
>>>>>
>>>>> ```
>>>>> string customerCode = 14;
>>>>> string status = 15 [json_name="statusCode"];
>>>>> string workStateTaxCode = 16;
>>>>> ```
>>>>>
>>>>> Any ideas or directions as always would be much appreciated. :)
>>>>> On Wednesday, November 17, 2021 at 9:58:40 AM UTC-7 
>>>>> [email protected] wrote:
>>>>>
>>>>>> I'm interested in the same feature. I'm curious to know if there are 
>>>>>> any good tutorials about using the descriptor.proto to map field names 
>>>>>> between protobuf field and json field. 
>>>>>>
>>>>>> Or it doesn't have to be a tutorial, it could just be a proto field I 
>>>>>> can use to experiment with.
>>>>>>
>>>>>> I'm struggling with json field names that contain ":" or "@". 
>>>>>>
>>>>>> On Wed, Nov 17, 2021 at 8:15 AM Josh Morehead <[email protected]> 
>>>>>> wrote:
>>>>>>
>>>>>>> Derek,
>>>>>>>
>>>>>>> That looks like it'll do exactly what I'm looking for.
>>>>>>> I'm in transit for work travel butI will definitely check this out 
>>>>>>> the min I land and get some time.
>>>>>>>
>>>>>>> Thanks!! I'll post back what happens. 
>>>>>>>
>>>>>>> On Tuesday, November 16, 2021 at 12:08:24 PM UTC-6 Derek Perez wrote:
>>>>>>>
>>>>>>>> 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/f6c5a8d5-c92b-46c7-8d58-e5cf4f486226n%40googlegroups.com
>>>>>>>  
>>>>>>> <https://groups.google.com/d/msgid/protobuf/f6c5a8d5-c92b-46c7-8d58-e5cf4f486226n%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/5fba6b74-a6c9-4bb9-a628-1173698c6a73n%40googlegroups.com
>>>>>  
>>>>> <https://groups.google.com/d/msgid/protobuf/5fba6b74-a6c9-4bb9-a628-1173698c6a73n%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/29b71fd0-2161-497f-9a4b-37f842c3ed0an%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/protobuf/29b71fd0-2161-497f-9a4b-37f842c3ed0an%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/ed8b7ddd-16f9-40d9-a5a1-224079f86aa7n%40googlegroups.com.

Reply via email to