Class: Fluent::Plugin::SerializeJSONParser
- Inherits:
-
Parser
- Object
- Parser
- Fluent::Plugin::SerializeJSONParser
- Defined in:
- lib/fluent/plugin/parser_serialize_nested_json.rb
Instance Method Summary collapse
Instance Method Details
#configure(conf) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/fluent/plugin/parser_serialize_nested_json.rb', line 12 def configure(conf) if conf.has_key?('time_format') conf['time_type'] ||= 'string' end super end |
#parse(text) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/fluent/plugin/parser_serialize_nested_json.rb', line 20 def parse(text) record = Yajl.load(text) values = Hash.new record.each do |k, v| if v.is_a?(Hash) || v.is_a?(Array) begin values[k] = Yajl::Encoder.encode(v) record.delete k rescue Exception => e # continue end end end record.merge!(values) time, record = convert_values(parse_time(record), record) yield time, record rescue Yajl::ParseError yield nil, nil end |