summaryrefslogtreecommitdiff
path: root/lib/hashie/hash.rb
diff options
context:
space:
mode:
authorDaniel Neighman <has.sox@gmail.com>2010-06-15 14:16:25 +0800
committerMichael Bleigh <michael@intridea.com>2010-06-22 22:00:39 +0800
commit0c85e9482f0ca0232d7cf7cf6577a359ea07ffed (patch)
tree34a2dd820c3e78721b3931a87b8a91b28f1091eb /lib/hashie/hash.rb
parenta026498fb732eeb8ad9bdb11bf28d21d8c0e3467 (diff)
downloadhashie-0c85e9482f0ca0232d7cf7cf6577a359ea07ffed.tar.gz
Adds a fix for json generation
Diffstat (limited to 'lib/hashie/hash.rb')
-rw-r--r--lib/hashie/hash.rb16
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/hashie/hash.rb b/lib/hashie/hash.rb
index d13a58b..906563c 100644
--- a/lib/hashie/hash.rb
+++ b/lib/hashie/hash.rb
@@ -4,5 +4,19 @@ module Hashie
# not be available in all libraries.
class Hash < Hash
include Hashie::HashExtensions
+
+ # Converts a mash back to a hash (with stringified keys)
+ def to_hash
+ out = {}
+ keys.each do |k|
+ out[k] = Hashie::Hash === self[k] ? self[k].to_hash : self[k]
+ end
+ out
+ end
+
+ # The C geneartor for the json gem doesn't like mashies
+ def to_json
+ to_hash.to_json
+ end
end
-end \ No newline at end of file
+end