指定protobuf扩展名的JSON名称 [英] Specifying the JSON name for protobuf extension
问题描述
我已经在消息中添加了扩展消息,需要将其封送为json.但是,扩展消息的字段名称为 [message.extension_message_name]
.
I've added an extending message to a message and need to marshal it as a json. However the field name for the extension message is [message.extension_message_name]
.
我希望将其命名为 extension_message_name
,而不使用花括号和前缀,因为此扩展消息存在于我们API的其他位置,并且具有此怪异的名称会增加混乱.
I would prefer it to be named just extension_message_name
, without the braces and prefix, since this extension message exists elsewhere in our API and and having this weird name adds confusion.
据我所知,负责的代码在 protobuf/jsonpb ,其中JSONName是使用 fmt.Sprintf("[%s]",desc.Name
设置的,似乎无法覆盖.
As far as I can tell the bit of code responsible is in protobuf/jsonpb, where the JSONName is set with fmt.Sprintf("[%s]", desc.Name
and cannot be overwritten it seems.
有人对此有解决方法吗?
Anyone have a workaround for this?