Skip to content

Commit 3a02c3b

Browse files
authored
Merge pull request #88 from Watson1978/yajl-to-json
Replace yajl-ruby with the json gem for JSON handling
2 parents 39717c2 + ea59ebc commit 3a02c3b

3 files changed

Lines changed: 3 additions & 6 deletions

File tree

fluent-plugin-out-http.gemspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ Gem::Specification.new do |gem|
1717

1818
gem.required_ruby_version = '>= 2.1.0'
1919

20-
gem.add_runtime_dependency "yajl-ruby", "~> 1.0"
2120
gem.add_runtime_dependency "fluentd", [">= 0.14.22", "< 2"]
2221
gem.add_development_dependency "bundler"
2322
gem.add_development_dependency "rake"

lib/fluent/plugin/out_http.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
require 'net/http'
22
require 'uri'
3-
require 'yajl'
43
require 'fluent/plugin/output'
54
require 'tempfile'
65
require 'openssl'
@@ -165,7 +164,7 @@ def compress_body(req, data)
165164
end
166165

167166
def set_json_body(req, data)
168-
req.body = Yajl.dump(data)
167+
req.body = JSON.generate(data)
169168
req['Content-Type'] = 'application/json'
170169
compress_body(req, req.body)
171170
end

test/plugin/test_out_http.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# -*- coding: utf-8 -*-
22
require 'net/http'
33
require 'uri'
4-
require 'yajl'
54
require 'fluent/test/http_output_test'
65
require 'fluent/plugin/out_http'
76
require 'fluent/test/driver/output'
@@ -121,7 +120,7 @@ def setup
121120

122121
record = {:auth => nil}
123122
if req.content_type == 'application/json'
124-
record[:json] = Yajl.load(expander.call(req))
123+
record[:json] = JSON.parse(expander.call(req))
125124
elsif req.content_type == 'text/plain'
126125
puts req
127126
record[:data] = expander.call(req)
@@ -130,7 +129,7 @@ def setup
130129
elsif req.content_type == 'application/x-ndjson'
131130
data = []
132131
expander.call(req).each_line { |l|
133-
data << Yajl.load(l)
132+
data << JSON.parse(l)
134133
}
135134
record[:x_ndjson] = data
136135
else

0 commit comments

Comments
 (0)