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

Merge pull request #17691 from nickveys/from-json-docs

Documentation regression in JSON#from_json
This commit is contained in:
Rafael Mendonça França 2014-11-26 13:45:27 -02:00
commit 13cb45452a

View file

@ -130,10 +130,10 @@ module ActiveModel
#
# json = { person: { name: 'bob', age: 22, awesome:true } }.to_json
# person = Person.new
# person.from_json(json) # => #<Person:0x007fec5e7a0088 @age=22, @awesome=true, @name="bob">
# person.name # => "bob"
# person.age # => 22
# person.awesome # => true
# person.from_json(json, true) # => #<Person:0x007fec5e7a0088 @age=22, @awesome=true, @name="bob">
# person.name # => "bob"
# person.age # => 22
# person.awesome # => true
def from_json(json, include_root=include_root_in_json)
hash = ActiveSupport::JSON.decode(json)
hash = hash.values.first if include_root