Chris G.
Chris G.

Reputation: 25934

json tag in .proto file

I am trying to generate go structs incl. json tags.

I can do:

string name = 1 [json_name="item.name, omitempty"];

But that only generates - json=item.name and only json:"name,omitempty"

Name string `protobuf:"bytes,1,opt,name=name,json=item.name, omitempty,proto3" json:"name,omitempty"`

But I need:- json:"item.name,omitempty" Note the tag is missing "item.". And it looks like no matter what you put in json_name it is not reflected in "json:"

Du you know how to set json tags?

Upvotes: 2

Views: 4192

Answers (1)

rubens21
rubens21

Reputation: 801

Not supported. The proto file json_name is not used to generate the code. https://github.com/golang/protobuf/issues/52

I also thought it was a bug https://github.com/golang/protobuf/issues/998

Upvotes: 1

Related Questions