From 7b8f571756792ed2296a766c70af4ddf69082099 Mon Sep 17 00:00:00 2001 From: Ewout Date: Tue, 20 Feb 2018 16:58:58 +0100 Subject: Ruby JSON encoding omits zero-length repeated fields by default. This makes it behave the same way as the other implementations. It is also nice to always encode an empty message as {}. --- ruby/tests/basic.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'ruby/tests') diff --git a/ruby/tests/basic.rb b/ruby/tests/basic.rb index ad34d53d..cadb1380 100644 --- a/ruby/tests/basic.rb +++ b/ruby/tests/basic.rb @@ -1259,6 +1259,10 @@ module BasicTest Foo.encode_json(Foo.new(bar: bar, baz: [baz1, baz2])) end + def test_json_empty + assert TestMessage.encode_json(TestMessage.new) == '{}' + end + def test_json_emit_defaults # TODO: Fix JSON in JRuby version. return if RUBY_PLATFORM == "java" -- cgit v1.2.3