I've been struggling with passing a JSON with Message values back and forth
between a browser (grpc-web) and server (python grpc). A Struct seems to be
the way but even though the struct I'm sending looks perfectly fine, it is
empty once received by the server.
```
// proto
message Result {
google.protobuf.Struct variables = 1;
}
// obj - Where variables would contain a (1 level deep) JSON with different
types of values, e.g.:
{
"key1": 1,
"key2": true,
"key3": proto_msg_a //instance of proto.MessageA
}
// code (js in browser using grpc-web)
struct = new proto.google.protobuf.Struct(obj);
req = new Request;
req.variables = struct;
```
Checking `req.variables` before sending shows that it's indeed a `Struct`
with all the correct fields in it. But once the other end (server) receives
it `req.variables` is an empty `Struct`. For testing purposes I tried an
`obj` that is simply `{'key': 'value'}`, but the result was the same.
I would really like to use proto messages in variables. The reason for
picking protobuf/grpc was exactly this, being able to use the same type
throughout our complete platform, but this seems to be blocking this goal.
Did I miss something? What would you do?
I've also asked this on StackOverflow:
https://stackoverflow.com/questions/62693938/grpc-passing-json-with-proto-message-field-between-browser-and-server
--
You received this message because you are subscribed to the Google Groups
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/grpc-io/770be5e7-1e0d-4835-9713-664ffc1cf4f1o%40googlegroups.com.