module ActiveModel::Serializers::JSON

def from_json(json, include_root = include_root_in_json)

person.awesome # => true
person.age # => 22
person.name # => "bob"
person.from_json(json, true) # => #
person = Person.new
json = { person: { name: 'bob', age: 22, awesome:true } }.to_json

+true+ if the given JSON string includes a single root node.
The default value for +include_root+ is +false+. You can change it to

person.awesome # => true
person.age # => 22
person.name # => "bob"
person.from_json(json) # => #
person = Person.new
json = { name: 'bob', age: 22, awesome:true }.to_json

end
end
instance_values
def attributes

end
end
send("#{key}=", value)
hash.each do |key, value|
def attributes=(hash)

attr_accessor :name, :age, :awesome

include ActiveModel::Serializers::JSON
class Person

Sets the model +attributes+ from a JSON string. Returns +self+.
def from_json(json, include_root = include_root_in_json)
  hash = ActiveSupport::JSON.decode(json)
  hash = hash.values.first if include_root
  self.attributes = hash
  self
end