Skip to content

Instantly share code, notes, and snippets.

@toretore
Forked from graingert/flatten.rb
Last active Oct 14, 2015
Embed
What would you like to do?
module Fluent
class TextParser
class StringifiedValuesJSONParser < JSONParser
Plugin.register_parser("stringified_values_json", self)
def parse(text)
time, record = super(text)
# replace all Hash (like a dict) values with stringified JSON
record = record.inject({}) { | new_hash, (key, value) |
if value.is_a?(Hash)
new_hash[key] = JSON.dump(value)
else
new_hash[key] = v
end
new_hash
}
yield time, record
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment