Skip to content

Commit 68cb3af

Browse files
committed
Tweak ActiveSupport::JSON.decode method description
I'm not sure if back in the day `MultiJson.decode` could decode non-object JSON objects -- but `JSON.parse` sure can now. ```ruby bundle exec rails runner 'p ActiveSupport::JSON.decode("2.39")' 2.39 ``` ref: rails@21fee1b
1 parent 0ed3cd4 commit 68cb3af

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

activesupport/lib/active_support/json/decoding.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ module JSON
1414
DATETIME_REGEX = /\A(?:\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})?)?)\z/
1515

1616
class << self
17-
# Parses a JSON string (JavaScript Object Notation) into a hash.
17+
# Parses a JSON string (JavaScript Object Notation) into a Ruby object.
1818
# See http://www.json.org for more info.
1919
#
2020
# ActiveSupport::JSON.decode("{\"team\":\"rails\",\"players\":\"36\"}")
2121
# => {"team" => "rails", "players" => "36"}
22+
# ActiveSupport::JSON.decode("2.39")
23+
# => 2.39
2224
def decode(json, options = {})
2325
data = ::JSON.parse(json, options)
2426

0 commit comments

Comments
 (0)