My goal is to send and receive data to/from a NodeJS microservice. The problem is that both my request and response objects are quite dynamic - fields with string | number
union types, maps with a set of predefined keys and then some dynamic ones. Converting this into protobuf3
structures proves to be an uneasy task and furthermore, google.protobuf.Any
seems to not be available for @grpc/proto-loader
, so I can't utilize it.
However if I send a JSON.stringify
-ed payload and then JSON.parse
it, there seems to be no problem, as my proto message includes a single string
field with the manually serialized payload.
Is this approach acceptable? I know there must be some overhead in the manual serialization but it does seem to get the job done. Am I missing something?
Any help is greatly appreciated.