Skip to content
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

[Ruby] Encoding JSON produces invalid JSON with empty StringValue wrapper. #6903

Closed
mintyfresh opened this issue Nov 18, 2019 · 1 comment · Fixed by #7198
Closed

[Ruby] Encoding JSON produces invalid JSON with empty StringValue wrapper. #6903

mintyfresh opened this issue Nov 18, 2019 · 1 comment · Fixed by #7198

Comments

@mintyfresh
Copy link

mintyfresh commented Nov 18, 2019

What version of protobuf and what language are you using?
Version: google-protobuf (3.9.2)
Language: Ruby

What operating system (Linux, Windows, ...) and version?
Ubuntu 18.04.2 LTS inside of WSL 2 (Windows Built 19018)

What runtime / compiler are you using (e.g., python version or gcc version)
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-linux]

What did you do?
Steps to reproduce the behavior:

  1. Define message containing StringValue field (defined by wrappers.proto).
  2. Construct message object with StringValue wrapper containing empty String.
  3. Encode message into JSON.

Example message type:

import "google/protobuf/wrappers.proto";

message User {
  google.protobuf.StringValue email = 1;
}

Example serialization:

user = User.new(email: Google::Protobuf::StringValue.new(value: ''))

User.encode_json(user)

What did you expect to see
Valid JSON string with empty key omitted:

{}

Or key containing empty wrapper object:

{"email": {}}

What did you see instead?
Invalid JSON string containing key with no value:

{"email":}
@sandlerben
Copy link

Also have this issue. Could you add a ruby tag to this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants