diff --git a/lang/ruby/avro.gemspec b/lang/ruby/avro.gemspec index ee4778e88fb..42b290265fd 100644 --- a/lang/ruby/avro.gemspec +++ b/lang/ruby/avro.gemspec @@ -39,5 +39,6 @@ Gem::Specification.new do |s| s.test_files = files.select { |f| f.start_with?("test/") } s.require_paths = ["lib"] - s.add_dependency("multi_json", "~> 1.0") + s.add_dependency("json", ">= 2.0") + s.add_dependency("bigdecimal") # not part of default gems since Ruby 3.4.0 end diff --git a/lang/ruby/lib/avro.rb b/lang/ruby/lib/avro.rb index 54cb99b4b14..7b6df71c553 100644 --- a/lang/ruby/lib/avro.rb +++ b/lang/ruby/lib/avro.rb @@ -15,7 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'multi_json' +require 'json' require 'set' require 'digest/md5' require 'net/http' diff --git a/lang/ruby/lib/avro/protocol.rb b/lang/ruby/lib/avro/protocol.rb index fb13b5a2056..3c61c89c463 100644 --- a/lang/ruby/lib/avro/protocol.rb +++ b/lang/ruby/lib/avro/protocol.rb @@ -23,7 +23,8 @@ class ProtocolParseError < Avro::AvroError; end attr_reader :name, :namespace, :types, :messages, :md5, :doc def self.parse(protocol_string) - json_data = MultiJson.load(protocol_string) + # `create_additions`` is false by default, quirks_mode no longer existing since json 2.0 + json_data = JSON.parse(protocol_string) if json_data.is_a? Hash name = json_data['protocol'] @@ -61,7 +62,7 @@ def initialize(name, namespace=nil, types=nil, messages=nil, doc=nil) end def to_s - MultiJson.dump to_avro + JSON.dump to_avro end def ==(other) @@ -136,7 +137,7 @@ def to_avro(names=Set.new) end def to_s - Yajl.dump to_avro + JSON.dump to_avro end def parse_request(request, names) diff --git a/lang/ruby/lib/avro/schema.rb b/lang/ruby/lib/avro/schema.rb index 37e1d21031c..0e25044be26 100644 --- a/lang/ruby/lib/avro/schema.rb +++ b/lang/ruby/lib/avro/schema.rb @@ -42,7 +42,7 @@ class Schema DECIMAL_LOGICAL_TYPE = 'decimal' def self.parse(json_string) - real_parse(MultiJson.load(json_string), {}) + real_parse(JSON.parse(json_string), {}) end # Build Avro Schema from data parsed out of JSON string. @@ -236,7 +236,7 @@ def to_avro(_names=nil) end def to_s - MultiJson.dump to_avro + JSON.dump to_avro end def validate_aliases! diff --git a/lang/ruby/lib/avro/schema_normalization.rb b/lang/ruby/lib/avro/schema_normalization.rb index 6a9de9c5609..c4a6d8f4737 100644 --- a/lang/ruby/lib/avro/schema_normalization.rb +++ b/lang/ruby/lib/avro/schema_normalization.rb @@ -26,7 +26,7 @@ def initialize end def to_parsing_form(schema) - MultiJson.dump(normalize_schema(schema)) + JSON.dump(normalize_schema(schema)) end private diff --git a/lang/ruby/test/test_datafile.rb b/lang/ruby/test/test_datafile.rb index f2a45e07978..0a5940cee85 100644 --- a/lang/ruby/test/test_datafile.rb +++ b/lang/ruby/test/test_datafile.rb @@ -109,9 +109,9 @@ def test_differing_schemas_with_complex_objects end %w[fixed enum record error array map union].each do |s| - reader = MultiJson.load(writer_schema) + reader = JSON.parse(writer_schema) reader['fields'] = reader['fields'].reject{|f| f['type']['type'] == s} - Avro::DataFile.open('data.avr', 'r', MultiJson.dump(reader)) do |dr| + Avro::DataFile.open('data.avr', 'r', JSON.dump(reader)) do |dr| dr.each_with_index do |obj, i| reader['fields'].each do |field| assert_equal data[i][field['name']], obj[field['name']] diff --git a/lang/ruby/test/test_io.rb b/lang/ruby/test/test_io.rb index c2b5ffc722c..d4d1a055cc1 100644 --- a/lang/ruby/test/test_io.rb +++ b/lang/ruby/test/test_io.rb @@ -561,8 +561,7 @@ def check(str) # test that the round-trip didn't mess up anything # NB: I don't think we should do this. Why enforce ordering? - assert_equal(MultiJson.load(str), - MultiJson.load(parsed_string)) + assert_equal(JSON.parse(str), JSON.parse(parsed_string)) # test __eq__ assert_equal(schema, Avro::Schema.parse(str))