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: wrapper types initialized to zero do not correctly serialize as json #6754

Closed
fables-tales opened this issue Oct 11, 2019 · 2 comments · Fixed by #7198
Closed

Ruby: wrapper types initialized to zero do not correctly serialize as json #6754

fables-tales opened this issue Oct 11, 2019 · 2 comments · Fixed by #7198

Comments

@fables-tales
Copy link
Contributor

$ cat Gemfile.lock
GEM
  remote: https://rubygems.org/
  specs:
    google-protobuf (3.9.2)

PLATFORMS
  ruby

DEPENDENCIES
  google-protobuf

BUNDLED WITH
   2.0.2
$ cat hi.rb
require 'google/protobuf'
require 'google/protobuf/wrappers_pb'
Google::Protobuf::DescriptorPool.generated_pool.build do
  add_message "Henlo" do
    optional :resource_name, :message, 1, "google.protobuf.Int32Value"
    optional :name, :string, 2
  end
end

Henlo  = Google::Protobuf::DescriptorPool.generated_pool.lookup("Henlo").msgclass

puts Henlo.new(name: "hi").to_json
puts Henlo.new(name: "hi", resource_name: Google::Protobuf::Int32Value.new(value: 0)).to_json
puts Henlo.new(name: "hi", resource_name: Google::Protobuf::Int32Value.new(value: 1)).to_json
$ bundle exec ruby hi.rb
{"name":"hi"}
{"resourceName":,"name":"hi"}
{"resourceName":1,"name":"hi"}

I would have expected the middle line to be {"resourceName": 0,"name":"hi"}

@sandlerben
Copy link

+1, also seeing this

@sandlerben
Copy link

See also #6903

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