20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/fluent/plugin/parser_json_in_json.rb', line 20
def parse(text)
record = Yajl.load(text)
values = Hash.new
record.each do |k, v|
if v.is_a?(String) && /^\s*(\{|\[)/ =~ v
begin
deserialized = Yajl.load(v)
if deserialized.is_a?(Hash)
values.merge!(deserialized)
record.delete k
elsif deserialized.is_a?(Array)
values[k] = deserialized
end
rescue Yajl::ParseError
end
end
end
record.merge!(values)
time, record = convert_values(parse_time(record), record)
yield time, record
rescue Yajl::ParseError
yield nil, nil
end
|