1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

add example to ActiveSupport::JSON.encode [ci skip]

This commit is contained in:
Francesco Rodriguez 2012-05-28 03:10:51 -05:00
parent a3d18d2ec0
commit 070fb46295

View file

@ -25,7 +25,10 @@ module ActiveSupport
# matches YAML-formatted dates # 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})?))$/ 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) def self.encode(value, options = nil)
Encoding::Encoder.new(options).encode(value) Encoding::Encoder.new(options).encode(value)
end end