Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/multi_json/adapters/json_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ def load(string, options = {})
end

def dump(object, options = {})
options.merge!(::JSON::PRETTY_STATE_PROTOTYPE.to_h) if options.delete(:pretty)
if options.delete(:pretty)
options.merge!({
indent: ' ',
space: ' ',
object_nl: "\n",
array_nl: "\n",
})
end

object.to_json(options)
end
end
Expand Down
1 change: 0 additions & 1 deletion spec/shared/adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
let(:json_pure){ Kernel.const_get('MultiJson::Adapters::JsonPure') rescue nil }

it "dumps time in correct format" do
pending "https://github.com/flori/json/issues/573" if json_pure
time = Time.at(1_355_218_745).utc

dumped_json = MultiJson.dump(time)
Expand Down
7 changes: 6 additions & 1 deletion spec/shared/json_common_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
describe "with :pretty option set to true" do
it "passes default pretty options" do
object = "foo"
expect(object).to receive(:to_json).with(JSON::PRETTY_STATE_PROTOTYPE.to_h)
expect(object).to receive(:to_json).with({
indent: ' ',
space: ' ',
object_nl: "\n",
array_nl: "\n",
})
MultiJson.dump(object, pretty: true)
end
end
Expand Down
Loading