-
-
Save toretore/a63fcf3e17d47723d87f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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