Skip to content

Commit

Permalink
add example to ActiveSupport::JSON.encode [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesco Rodriguez committed May 28, 2012
1 parent a3d18d2 commit 070fb46
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion activesupport/lib/active_support/json/encoding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ module JSON
# matches YAML-formatted dates
DATE_REGEX = /^(?:\d{4}-\d{2}-\d{2}|\d{4}-\d{1,2}-\d{1,2}[T \t]+\d{1,2}:\d{2}:\d{2}(\.[0-9]*)?(([ \t]*)Z|[-+]\d{2}?(:\d{2})?))$/

# Dumps object in JSON (JavaScript Object Notation). See www.json.org for more info.
# Dumps objects in JSON (JavaScript Object Notation). See www.json.org for more info.
#
# ActiveSupport::JSON.encode({team: 'rails', players: '36'})
# # => "{\"team\":\"rails\",\"players\":\"36\"}"
def self.encode(value, options = nil)
Encoding::Encoder.new(options).encode(value)
end
Expand Down

0 comments on commit 070fb46

Please sign in to comment.