From 3202fbabe6df3591d7e2c35727ea9c8b68df8828 Mon Sep 17 00:00:00 2001 From: Sam Stephenson Date: Sun, 18 Mar 2007 07:05:58 +0000 Subject: Refactor ActiveSupport::JSON to be less obtuse. Add support for JSON decoding by way of Syck with ActiveSupport::JSON.decode(json_string). Prevent hash keys that are JavaScript reserved words from being unquoted during encoding. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6443 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/lib/active_support/json/encoders/enumerable.rb | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 activesupport/lib/active_support/json/encoders/enumerable.rb (limited to 'activesupport/lib/active_support/json/encoders/enumerable.rb') diff --git a/activesupport/lib/active_support/json/encoders/enumerable.rb b/activesupport/lib/active_support/json/encoders/enumerable.rb new file mode 100644 index 0000000000..150d233939 --- /dev/null +++ b/activesupport/lib/active_support/json/encoders/enumerable.rb @@ -0,0 +1,5 @@ +module Enumerable + def to_json #:nodoc: + "[#{map { |value| ActiveSupport::JSON.encode(value) } * ', '}]" + end +end -- cgit v1.2.3