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:
parent
a3d18d2ec0
commit
070fb46295
1 changed files with 4 additions and 1 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue