You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First off, I apologize if this problem has been raised in another issue. I looked over them and couldn't find one that directory talked about a work around for this problem. The closest I found was #677 . But I don't understand how to apply the suggestion of wrappers from OUR code (not protobufJS's source code).
So we use "wrapper" values such as google.protobuf.StringValue and google.protobuf.DoubleValue to handle distinguishing between null and default. We are facing two problems related to creating and sending JSON from messages that contain these wrapped values.
In our server code we transmit this message as JSON on our endpoints in Python. When we create JSON from protobuf instances on the server using MessageToDict or MessageToJSON we end up with the following:
In the UI we have the same model compiled with ProtobufJS/ProtobufTS. There are two problems we're having.
The first is that we're not able to take this JSON payload and turn it back into an Alarm in the UI since the JSON structure doesn't have wrapped values. Essentially there is a mismatch between the JSON created from a message and the JSON needed to create a message.
At the very least I'd like to be able to use fromObject / toObject to consume the JSON to make a new Alarm or to produce JSON from an existing Alarm.
This issue describes what I'm talking about and someone has made a PR to allow us to write wrappers for the wrapped values (#677 (comment)). What I don't understand where do I include this wrapper code? Basically in our project we have a .proto file and we compile it with protobufJS.
Where do I define these wrappers and how can I include them when I compile our .proto files?
The second problem is there is no interface available in the UI TS files to describe the JSON structure. The JavaScript interface of an Alarm for instance doesn't need wrapped values. So if we want to use the JSON structure that we get from the server we have to manually create an interface for each of our messages that matches the JSON version of message.
I understand I could just use the Protobuf interface which has wrappers rather than primitives but it means dealing with the extra .value everywhere and not having an interface to describe the actual JSON data that will get sent back to the server for updates.
The text was updated successfully, but these errors were encountered:
First off, I apologize if this problem has been raised in another issue. I looked over them and couldn't find one that directory talked about a work around for this problem. The closest I found was #677 . But I don't understand how to apply the suggestion of wrappers from OUR code (not protobufJS's source code).
So we use "wrapper" values such as
google.protobuf.StringValue
andgoogle.protobuf.DoubleValue
to handle distinguishing between null and default. We are facing two problems related to creating and sending JSON from messages that contain these wrapped values.Given a message with the following structure:
In our server code we transmit this message as JSON on our endpoints in Python. When we create JSON from protobuf instances on the server using MessageToDict or MessageToJSON we end up with the following:
In the UI we have the same model compiled with ProtobufJS/ProtobufTS. There are two problems we're having.
The first is that we're not able to take this JSON payload and turn it back into an
Alarm
in the UI since the JSON structure doesn't have wrapped values. Essentially there is a mismatch between the JSON created from a message and the JSON needed to create a message.At the very least I'd like to be able to use
fromObject
/toObject
to consume the JSON to make a new Alarm or to produce JSON from an existing Alarm.This issue describes what I'm talking about and someone has made a PR to allow us to write wrappers for the wrapped values (#677 (comment)). What I don't understand where do I include this wrapper code? Basically in our project we have a
.proto
file and we compile it with protobufJS.Where do I define these wrappers and how can I include them when I compile our
.proto
files?The second problem is there is no interface available in the UI TS files to describe the JSON structure. The JavaScript interface of an Alarm for instance doesn't need wrapped values. So if we want to use the JSON structure that we get from the server we have to manually create an interface for each of our messages that matches the JSON version of message.
I understand I could just use the Protobuf interface which has wrappers rather than primitives but it means dealing with the extra
.value
everywhere and not having an interface to describe the actual JSON data that will get sent back to the server for updates.The text was updated successfully, but these errors were encountered: