diff --git a/lib/fluent/env.rb b/lib/fluent/env.rb index 29f1d38635..a626dd3e53 100644 --- a/lib/fluent/env.rb +++ b/lib/fluent/env.rb @@ -18,7 +18,7 @@ module Fluent DEFAULT_CONFIG_PATH = ENV['FLUENT_CONF'] || '/etc/fluent/fluent.conf' DEFAULT_PLUGIN_DIR = ENV['FLUENT_PLUGIN'] || '/etc/fluent/plugin' DEFAULT_SOCKET_PATH = ENV['FLUENT_SOCKET'] || '/var/run/fluent/fluent.sock' - DEFAULT_OJ_OPTIONS = {bigdecimal_load: :float, mode: :compat} + DEFAULT_OJ_OPTIONS = {bigdecimal_load: :float, mode: :compat, use_to_json: true} IS_WINDOWS = /mswin|mingw/ === RUBY_PLATFORM private_constant :IS_WINDOWS diff --git a/test/test_event_time.rb b/test/test_event_time.rb index 3f7a3d6b16..0c74d209e9 100644 --- a/test/test_event_time.rb +++ b/test/test_event_time.rb @@ -51,7 +51,9 @@ class EventTimeTest < Test::Unit::TestCase test 'Oj.dump' do time = Fluent::EventTime.new(100) - assert_equal('{"time":100}', Oj.dump({'time' => time}, mode: :compat)) + require 'fluent/env' + Oj.default_options = Fluent::DEFAULT_OJ_OPTIONS + assert_equal('{"time":100}', Oj.dump({'time' => time})) assert_equal('["tag",100,{"key":"value"}]', Oj.dump(["tag", time, {"key" => "value"}], mode: :compat)) end