Created
September 22, 2015 15:24
-
-
Save kaspergrubbe/003b66e3e0c4acaf8a33 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def deep_munge(hash) | |
hash.each do |k, v| | |
case v | |
when Array | |
v.grep(Hash) { |x| deep_munge(x) } | |
v.compact! | |
hash[k] = nil if v.empty? | |
when Hash | |
deep_munge(v) | |
end | |
end | |
hash | |
end | |
params = {} | |
params["fees"]={"ranges"=>["100.0"], "values"=>["0.00"], "range0"=>"0.0"} | |
deep_munge(params) | |
# observe |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment