aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/json/encoding.rb
diff options
context:
space:
mode:
authorAlexey Nayden <alexey.nayden@gmail.com>2011-01-13 03:17:47 +0300
committerSantiago Pastorino <santiago@wyeworks.com>2011-01-15 00:06:26 -0200
commita9163b547c7cfd4861c814371fa9d1a6bdb31231 (patch)
tree1cc7dec365132bb54306814c9ba53ee8a92eb982 /activesupport/lib/active_support/json/encoding.rb
parentd2c17dbd11417012c47b9ac48c62651a1415de5d (diff)
downloadrails-a9163b547c7cfd4861c814371fa9d1a6bdb31231.tar.gz
rails-a9163b547c7cfd4861c814371fa9d1a6bdb31231.tar.bz2
rails-a9163b547c7cfd4861c814371fa9d1a6bdb31231.zip
Complex struct encoding fix
[#6077 state:committed] Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
Diffstat (limited to 'activesupport/lib/active_support/json/encoding.rb')
-rw-r--r--activesupport/lib/active_support/json/encoding.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/json/encoding.rb b/activesupport/lib/active_support/json/encoding.rb
index c8cac52027..b2ea196003 100644
--- a/activesupport/lib/active_support/json/encoding.rb
+++ b/activesupport/lib/active_support/json/encoding.rb
@@ -153,6 +153,12 @@ class Object
end
end
+class Struct
+ def as_json(options = nil) #:nodoc:
+ Hash[members.zip(values)]
+ end
+end
+
class TrueClass
AS_JSON = ActiveSupport::JSON::Variable.new('true').freeze
def as_json(options = nil) AS_JSON end #:nodoc: