Skip to content

Instantly share code, notes, and snippets.

@onefriendaday
Created October 16, 2015 21:03
Show Gist options
  • Save onefriendaday/286daf85f038254529a6 to your computer and use it in GitHub Desktop.
Save onefriendaday/286daf85f038254529a6 to your computer and use it in GitHub Desktop.
json = {
"component": "root",
"body": [
{
"component": "headline",
"text": "42323"
}
]
}
class Hash
def insert_uuids()
if not self.is_a?(Hash) and not self.is_a?(Array)
return
end
if self.is_a?(Hash)
self[:uid] = 'some random uid'
end
self.each do |arr, val|
if val.is_a?(Hash)
arr.insert_uuids()
end
end
self
end
end
puts json.insert_uuids()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment