mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
3202fbabe6
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6443 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
12 lines
359 B
Ruby
12 lines
359 B
Ruby
class Hash
|
|
def to_json #:nodoc:
|
|
returning result = '{' do
|
|
result << map do |key, value|
|
|
key = ActiveSupport::JSON::Variable.new(key.to_s) if
|
|
ActiveSupport::JSON.can_unquote_identifier?(key)
|
|
"#{ActiveSupport::JSON.encode(key)}: #{ActiveSupport::JSON.encode(value)}"
|
|
end * ', '
|
|
result << '}'
|
|
end
|
|
end
|
|
end
|