-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[JSONPB] Invalid conversion between json and protbuf #347
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
Comments
I try to add message VirtualMachine {
string name = 1;
int32 memory = 2;
int32 num_cpu = 3;
string power_state = 4 [json_name="powerState"];
string host = 5;
repeated Disk disks = 6;
repeated CloudNetwork nics = 7;
} Generated struct is : type VirtualMachine struct {
Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
Memory int32 `protobuf:"varint,2,opt,name=memory" json:"memory,omitempty"`
NumCpu int32 `protobuf:"varint,3,opt,name=num_cpu,json=numCpu" json:"num_cpu,omitempty"`
PowerState string `protobuf:"bytes,4,opt,name=power_state,json=powerState" json:"power_state,omitempty"`
Host string `protobuf:"bytes,5,opt,name=host" json:"host,omitempty"`
Disks []*Disk `protobuf:"bytes,6,rep,name=disks" json:"disks,omitempty"`
Nics []*CloudNetwork `protobuf:"bytes,7,rep,name=nics" json:"nics,omitempty"`
} Same error with the unit test. If i manually change the struct to that it works : type VirtualMachine struct {
Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
Memory int32 `protobuf:"varint,2,opt,name=memory" json:"memory,omitempty"`
NumCpu int32 `protobuf:"varint,3,opt,name=num_cpu,json=numCpu" json:"num_cpu,omitempty"`
PowerState string `protobuf:"bytes,4,opt,name=power_state,json=powerState" json:"powerState,omitempty"`
Host string `protobuf:"bytes,5,opt,name=host" json:"host,omitempty"`
Disks []*Disk `protobuf:"bytes,6,rep,name=disks" json:"disks,omitempty"`
Nics []*CloudNetwork `protobuf:"bytes,7,rep,name=nics" json:"nics,omitempty"`
} Perhaps related to #256 |
Hi, I'm trying to understand your test code. You call |
So I looked into this further and I'm going to close this as a issue in The logic in You are hitting this case because you are trying to unmarshal into a Feel free to file a bug against gRPC and reference this issue. |
OK. Thanks for your help. |
Hi,
i've got an error to convert JSON to Protobuf :
The proto file :
The test :
Any idea why "PowerState" is not set ?
Thanks
The text was updated successfully, but these errors were encountered: