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
2 changes: 1 addition & 1 deletion lib/fluent/command/cat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def abort_message(time, record)
when 'json'
begin
while line = $stdin.gets
record = JSON.parse(line, Fluent::DEFAULT_JSON_PARSE_OPTIONS)
record = JSON.parse(line, **Fluent::DEFAULT_JSON_PARSE_OPTIONS)
w.write(record)
end
rescue
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/compat/exec_util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class JSONParser < Parser
BYTES_TO_READ = 8192

def call(io)
parser = JSON::ResumableParser.new(Fluent::DEFAULT_JSON_PARSE_OPTIONS)
parser = JSON::ResumableParser.new(**Fluent::DEFAULT_JSON_PARSE_OPTIONS)
begin
chunk = +"".b
while io.readpartial(BYTES_TO_READ, chunk)
Expand Down
4 changes: 2 additions & 2 deletions lib/fluent/config/literal_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def scan_json(is_array)
# '{"foo":"bar", #' -> '{"foo":"bar"}' (to check)
parsed = nil
begin
parsed = JSON.parse(buffer + line_buffer.rstrip.sub(/,$/, '') + (is_array ? "]" : "}"), Fluent::DEFAULT_JSON_PARSE_OPTIONS)
parsed = JSON.parse(buffer + line_buffer.rstrip.sub(/,$/, '') + (is_array ? "]" : "}"), **Fluent::DEFAULT_JSON_PARSE_OPTIONS)
rescue JSON::ParserError
# This '#' is in json string literals
end
Expand Down Expand Up @@ -288,7 +288,7 @@ def scan_json(is_array)

line_buffer << char
begin
result = JSON.parse(buffer + line_buffer, Fluent::DEFAULT_JSON_PARSE_OPTIONS)
result = JSON.parse(buffer + line_buffer, **Fluent::DEFAULT_JSON_PARSE_OPTIONS)
rescue JSON::ParserError
# Incomplete json string yet
end
Expand Down
4 changes: 2 additions & 2 deletions lib/fluent/config/types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def self.hash_value(val, opts = {}, name = nil)
return nil if val.nil?

param = if val.is_a?(String)
val.start_with?('{') ? JSON.parse(val, Fluent::DEFAULT_JSON_PARSE_OPTIONS) : Hash[val.strip.split(/\s*,\s*/).map{|v| v.split(':', 2)}]
val.start_with?('{') ? JSON.parse(val, **Fluent::DEFAULT_JSON_PARSE_OPTIONS) : Hash[val.strip.split(/\s*,\s*/).map{|v| v.split(':', 2)}]
else
val
end
Expand All @@ -228,7 +228,7 @@ def self.array_value(val, opts = {}, name = nil)
return nil if val.nil?

param = if val.is_a?(String)
val.start_with?('[') ? JSON.parse(val, Fluent::DEFAULT_JSON_PARSE_OPTIONS) : val.strip.split(/\s*,\s*/)
val.start_with?('[') ? JSON.parse(val, **Fluent::DEFAULT_JSON_PARSE_OPTIONS) : val.strip.split(/\s*,\s*/)
elsif val.is_a?(Array)
val
elsif val.is_a?(Numeric) || val == true || val == false
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/daemon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@

server_module = Fluent.const_get(ARGV[0])
worker_module = Fluent.const_get(ARGV[1])
params = JSON.parse(ARGV[2], Fluent::DEFAULT_JSON_PARSE_OPTIONS)
params = JSON.parse(ARGV[2], **Fluent::DEFAULT_JSON_PARSE_OPTIONS)
ServerEngine::Daemon.run_server(server_module, worker_module) { Fluent::Supervisor.serverengine_config(params) }
2 changes: 1 addition & 1 deletion lib/fluent/plugin/filter_record_transformer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def filter_stream(tag, es)

def parse_value(value_str)
if value_str.start_with?('{', '[')
JSON.parse(value_str, Fluent::DEFAULT_JSON_PARSE_OPTIONS)
JSON.parse(value_str, **Fluent::DEFAULT_JSON_PARSE_OPTIONS)
else
value_str
end
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/plugin/in_forward.rb
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def read_messages(conn, &block)
unless feeder
first = data[0]
if first == '{' || first == '[' # json
parser = JSON::ResumableParser.new(Fluent::DEFAULT_JSON_PARSE_OPTIONS)
parser = JSON::ResumableParser.new(**Fluent::DEFAULT_JSON_PARSE_OPTIONS)
serializer = :to_json.to_proc
feeder = ->(d){
parser << d
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/plugin/in_monitor_agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def render_json(obj, code: 200, pretty_json: nil)
end

def render_ltsv(obj, code: 200)
normalized = JSON.parse(obj.to_json, Fluent::DEFAULT_JSON_PARSE_OPTIONS)
normalized = JSON.parse(obj.to_json, **Fluent::DEFAULT_JSON_PARSE_OPTIONS)
text = ''
normalized.each do |hash|
row = []
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/plugin/in_sample.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class SampleInput < Input
desc "The sample data to be generated. An array of JSON hashes or a single JSON hash."
config_param :sample, alias: :dummy, default: [{"message" => "sample"}] do |val|
begin
parsed = JSON.parse(val, Fluent::DEFAULT_JSON_PARSE_OPTIONS)
parsed = JSON.parse(val, **Fluent::DEFAULT_JSON_PARSE_OPTIONS)
rescue JSON::ParserError => ex
# Fluent::ConfigParseError, "got incomplete JSON" will be raised
# at literal_parser.rb with --use-v1-config, but I had to
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/plugin/in_unix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def on_read(data)
first = data[0]
if first == '{'.freeze || first == '['.freeze
m = method(:on_read_json)
@parser = JSON::ResumableParser.new(Fluent::DEFAULT_JSON_PARSE_OPTIONS)
@parser = JSON::ResumableParser.new(**Fluent::DEFAULT_JSON_PARSE_OPTIONS)
else
m = method(:on_read_msgpack)
@parser = Fluent::MessagePackFactory.msgpack_unpacker
Expand Down
4 changes: 2 additions & 2 deletions lib/fluent/plugin/parser_json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class JSONParser < Parser

# Use a shared proc rather than a per-call lambda so that
# configure_json_parser returns the same object every time.
JSON_PARSE_PROC = ->(text) { JSON.parse(text, Fluent::DEFAULT_JSON_PARSE_OPTIONS) }
JSON_PARSE_PROC = ->(text) { JSON.parse(text, **Fluent::DEFAULT_JSON_PARSE_OPTIONS) }

def configure(conf)
if conf.has_key?('time_format')
Expand Down Expand Up @@ -96,7 +96,7 @@ def parser_type
end

def parse_io(io, &block)
parser = JSON::ResumableParser.new(Fluent::DEFAULT_JSON_PARSE_OPTIONS)
parser = JSON::ResumableParser.new(**Fluent::DEFAULT_JSON_PARSE_OPTIONS)
begin
chunk = +"".b
while io.readpartial(@stream_buffer_size, chunk)
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/plugin/sd_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def parser
-> (v) { YAML.safe_load(v).map }
when :json
require 'json'
-> (v) { JSON.parse(v, Fluent::DEFAULT_JSON_PARSE_OPTIONS) }
-> (v) { JSON.parse(v, **Fluent::DEFAULT_JSON_PARSE_OPTIONS) }
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/fluent/plugin/storage_local.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def configure(conf)
log.warn "detect empty plugin storage file during startup. Ignored: #{@path}"
return
end
data = JSON.parse(data, Fluent::DEFAULT_JSON_PARSE_OPTIONS)
data = JSON.parse(data, **Fluent::DEFAULT_JSON_PARSE_OPTIONS)
raise Fluent::ConfigError, "Invalid contents (not object) in plugin storage file: '#{@path}'" unless data.is_a?(Hash)
rescue => e
log.error "failed to read data from plugin storage file", path: @path, error: e
Expand All @@ -114,7 +114,7 @@ def load
return unless File.exist?(@path)
begin
json_string = File.open(@path, 'r:utf-8:utf-8'){ |io| io.read }
json = JSON.parse(json_string, Fluent::DEFAULT_JSON_PARSE_OPTIONS)
json = JSON.parse(json_string, **Fluent::DEFAULT_JSON_PARSE_OPTIONS)
unless json.is_a?(Hash)
log.error "broken content for plugin storage (Hash required: ignored)", type: json.class
log.debug "broken content", content: json_string
Expand Down
Loading