-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
jsonpb: handle map keys' and values' properties properly #645
Conversation
FWIW, this does indeed fix things for me. |
@dsnet Could you please take a look at this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's really unfortunate that we have to expand the API surface of proto.Properties
. That API exists because we lack proper proto reflection and should be deprecated in the near future.
proto/properties.go
Outdated
mtype reflect.Type // set for map types only | ||
mkeyprop *Properties // set for map types only | ||
mvalprop *Properties // set for map types only | ||
MapType reflect.Type // set for map types only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not used in jsonpb
. Keep it unexported.
proto/properties.go
Outdated
mvalprop *Properties // set for map types only | ||
MapType reflect.Type // set for map types only | ||
MKeyProp *Properties // set for map types only | ||
MValProp *Properties // set for map types only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call these MapKeyProp
and MapValueProp
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MapKeyProp
& MapValProp
seems a bit prettier
This doesn't seem like it should be necessary. If these were added just so that jsonpb knows when a map value is an enum, there are other things that could be examined.
The latter might be even better addressed by tweaks to the patch in PR #630: don't treat enums the same as other |
export mkeyprop, mvalprop for jsonpb's usage. previously we use struct tag for map marshaling & unmarshaling, fix this.
@jhump Yes, but I want to make this more reasonable. For now, we only have @dsnet For now, as we only have Code updated per review comments. |
Ping @dsnet: my own repo is broken (dynamic message JSON tests, which rely on proper behavior in jsonpb) until #644 is fixed: https://travis-ci.org/jhump/protoreflect/builds |
Will this be in a release any time soon? |
Export
mtype
,mkeyprop
,mvalprop
fields fromproto.Properties
for usage outsideproto
package.Fix up
jsonpb
pending TODOs.Fixes #644