Skip to content

Commit

Permalink
Merge pull request #17691 from nickveys/from-json-docs
Browse files Browse the repository at this point in the history
Documentation regression in JSON#from_json
  • Loading branch information
rafaelfranca committed Nov 26, 2014
2 parents 25b14b4 + f78006d commit 13cb454
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions activemodel/lib/active_model/serializers/json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ def as_json(options = nil)
#
# 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
Expand Down

0 comments on commit 13cb454

Please sign in to comment.