Skip to content

Commit d3ebfcb

Browse files
committed
refactor: replace multi_json with stdlib json
1 parent 0695423 commit d3ebfcb

4 files changed

Lines changed: 5 additions & 6 deletions

File tree

hutch.gemspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ Gem::Specification.new do |gem|
99
gem.add_runtime_dependency 'bunny', '>= 3.1', '< 4.0'
1010
end
1111
gem.add_runtime_dependency 'carrot-top', '~> 0.0.7'
12-
gem.add_runtime_dependency 'multi_json', '~> 1.15'
1312
gem.add_runtime_dependency 'activesupport', '>= 4.2'
1413

1514
gem.name = 'hutch'

lib/hutch/serializers/json.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
require 'multi_json'
1+
require 'json'
22
require 'active_support/core_ext/hash/indifferent_access'
33

44
module Hutch
55
module Serializers
66
class JSON
77

88
def self.encode(payload)
9-
::MultiJson.dump(payload)
9+
::JSON.generate(payload)
1010
end
1111

1212
def self.decode(payload)
13-
::MultiJson.load(payload).with_indifferent_access
13+
::JSON.parse(payload).with_indifferent_access
1414
end
1515

1616
def self.binary? ; false ; end

spec/hutch/message_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
let(:delivery_info) { double('Delivery Info') }
55
let(:props) { double('Properties', content_type: "application/json") }
66
let(:body) {{ foo: 'bar' }.with_indifferent_access}
7-
let(:json_body) { MultiJson.dump(body) }
7+
let(:json_body) { JSON.generate(body) }
88
subject(:message) { Hutch::Message.new(delivery_info, props, json_body, Hutch::Config[:serializer]) }
99

1010
describe '#body' do

spec/hutch/worker_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def handle(_properties, _payload, _consumer, _ex)
191191

192192
context "when the payload is not valid json" do
193193
let(:payload) { "Not Valid JSON" }
194-
let(:expected_log) { /ERROR .+ error in consumer .+ MultiJson::ParseError .+ backtrace:/m }
194+
let(:expected_log) { /ERROR .+ error in consumer .+ JSON::ParserError .+ backtrace:/m }
195195

196196
it 'logs the error' do
197197
expect { subject }.to change { log.tap(&:rewind).read }.from("").to(expected_log)

0 commit comments

Comments
 (0)