-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
how to handle arbitrary (json) structs #395
Comments
This is not a gateway question, rather what you can map into protocol buffer. The short answer is, you can't define arbitrary To use protocol buffer, you need to know the |
yeah, i understand that the however, when using the gateway, i have to send the json request body as {
"key": "xyz",
"data": {
"fields": {
"name": {
"stringValue": "joe"
},
"age": {
"numberValue": 28
}
}
}
} which, while not ideal, does actual get parsed correctly by the gateway. |
I don't think you can do any better with |
As an alternative, you could use |
hmm.. somewhat doable, although things quickly get mucky with nested objects. oh well.. guess i'm outta luck. thanks for your time @tamalsaha. |
I'm pretty sure this can solve this for anyone else that finds this issue: https://godoc.org/github.com/golang/protobuf/jsonpb#Unmarshal |
@bobbytables Not quite sure what you mean. How does that let you map arbitrary json to a field? |
Thanks, I barely found how to use this thing, because. not in one guide google this is not written. Used shnake_case instead of camelCase based on type from proto file |
i haven't been able to find an example of how to support arbitrary json -> map[string]interface{}.
i've defined my
message
as:as
Struct
seems to be the appropriate json equivalent in protobuf.however, i am unable to invoke the corresponding REST endpoint using
is there a way to support arbitrary json content and have it mapped to basically a
map[string]interface{}
?not sure how I need to define my proto messages / services to support this.
The text was updated successfully, but these errors were encountered: