Created
May 3, 2015 18:07
-
-
Save skippy/89cafb280017d52a582c to your computer and use it in GitHub Desktop.
google-protobuf under jruby has broken JSON encoding
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# google-protobuf/master | |
require 'google/protobuf' | |
pool = Google::Protobuf::DescriptorPool.new | |
pool.build do | |
add_message 'ProtoMsg' do | |
repeated :msg_string, :string, 1 | |
end | |
end | |
ProtoMsg = pool.lookup('ProtoMsg').msgclass | |
pm = ProtoMsg.new | |
pm.msg_string += ['foo', 'bar'] | |
pm #=> <ProtoMsg: msg_string: ["foo", "bar"]> | |
puts ProtoMsg.encode_json(pm) | |
# {"msg_string":"#<Google::Protobuf::RepeatedField:0x1725dc0f>"} | |
# my patch | |
# ...... | |
pm #=> <ProtoMsg: msg_string: ["foo", "bar"]> | |
puts ProtoMsg.encode_json(pm) | |
# {"msg_string":["foo","bar"]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment