diff --git a/lang/ruby/avro.gemspec b/lang/ruby/avro.gemspec index ee4778e88fb..9a1d0a1e3fd 100644 --- a/lang/ruby/avro.gemspec +++ b/lang/ruby/avro.gemspec @@ -39,5 +39,5 @@ 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") 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..35192d9cacb 100644 --- a/lang/ruby/lib/avro/protocol.rb +++ b/lang/ruby/lib/avro/protocol.rb @@ -23,7 +23,7 @@ class ProtocolParseError < Avro::AvroError; end attr_reader :name, :namespace, :types, :messages, :md5, :doc def self.parse(protocol_string) - json_data = MultiJson.load(protocol_string) + json_data = JSON.parse(protocol_string, create_additions: false, quirks_mode: true) if json_data.is_a? Hash name = json_data['protocol'] @@ -61,7 +61,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 +136,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..0d36a77139e 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, create_additions: false, quirks_mode: true), {}) 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..fe553458c73 100644 --- a/lang/ruby/test/test_io.rb +++ b/lang/ruby/test/test_io.rb @@ -561,8 +561,8 @@ 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, quirks_mode: true), + JSON.parse(parsed_string, quirks_mode: true)) # test __eq__ assert_equal(schema, Avro::Schema.parse(str))