We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Describe the bug
When there is a value of [] in json string for a repeated field in protobuf definition, j2p will return err.
[]
To Reproduce
func main() { content := syntax = "proto3";
func main() { content :=
package pb3; option go_package = "pb/example";
message ExampleScalarsReq { optional string Msg = 1; optional double Cookie = 2; string Path = 3; repeated string Query = 4; bool Header = 5; int64 Code = 6; }
message ExampleScalarsResp { string Msg = 1; optional double Cookie = 2; int32 Status = 3; optional bool Header = 4; int64 Code = 5; double Subfix = 6; }
service TestService { rpc ScalarsMethodTest(ExampleScalarsReq) returns (ExampleScalarsResp); }` opts := proto.Options{} descriptor, err := opts.NewDesccriptorFromContent(context.Background(), "bugreport.proto", content, map[string]string{}) if err != nil { panic(err) } typeDescriptor := descriptor.Methods()["ScalarsMethodTest"].Input()
input := []byte(`{"Msg": "msg", "Query": [], "Header": false, "Code": 0}`) cv := j2p.NewBinaryConv(conv.Options{}) out, err := cv.Do(context.Background(), typeDescriptor, input) if err != nil { panic(err) } fmt.Println(string(out))
} `
Expected behavior
Empty list in json can be ignored or well handled when converting to protobuf.
Screenshots
Version:
v0.4.4
Environment:
The output of go env.
go env
Additional context
Remove the "Query": [] or put a value in the list, then it will return without error
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Describe the bug
When there is a value of
[]
in json string for a repeated field in protobuf definition, j2p will return err.To Reproduce
func main() { content :=
syntax = "proto3";package pb3;
option go_package = "pb/example";
message ExampleScalarsReq {
optional string Msg = 1;
optional double Cookie = 2;
string Path = 3;
repeated string Query = 4;
bool Header = 5;
int64 Code = 6;
}
message ExampleScalarsResp {
string Msg = 1;
optional double Cookie = 2;
int32 Status = 3;
optional bool Header = 4;
int64 Code = 5;
double Subfix = 6;
}
service TestService {
rpc ScalarsMethodTest(ExampleScalarsReq) returns (ExampleScalarsResp);
}`
opts := proto.Options{}
descriptor, err := opts.NewDesccriptorFromContent(context.Background(), "bugreport.proto", content, map[string]string{})
if err != nil {
panic(err)
}
typeDescriptor := descriptor.Methods()["ScalarsMethodTest"].Input()
}
`
Expected behavior
Empty list in json can be ignored or well handled when converting to protobuf.
Screenshots
Version:
v0.4.4
Environment:
The output of
go env
.Additional context
Remove the "Query": [] or put a value in the list, then it will return without error
The text was updated successfully, but these errors were encountered: