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 <josh_moreh...@trimble.com>
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 david....@umbra.space
> 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 <josh_m...@trimble.com>
>> 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 <josh_m...@trimble.com>
>>>> 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 <josh_m...@trimble.com>
>>>>>> 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 protobuf+u...@googlegroups.com.
>>>>>>> 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 <josh_m...@trimble.com>
>>>>>> 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 protobuf+u...@googlegroups.com.
>>>>>>> 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 protobuf+u...@googlegroups.com.
>>>>>
>>>> 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 protobuf+u...@googlegroups.com.
>>>
>> 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 protobuf+unsubscr...@googlegroups.com.
> 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 protobuf+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/CAJGs%2Bi%2BorRwOwvgkOwyZnGw6b4DSTXH8RjbuVK%2BtPyENvjypAg%40mail.gmail.com.

Reply via email to