File: //usr/local/rvm/gems/default/doc/activemodel-6.1.4.1/ri/ActiveModel/Serializers/JSON/from_json-i.ri
U:RDoc::AnyMethod[iI"from_json:ETI"-ActiveModel::Serializers::JSON#from_json;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"DSets the model +attributes+ from a JSON string. Returns +self+.;To:RDoc::Markup::BlankLine o:RDoc::Markup::Verbatim; [I"class Person
;TI". include ActiveModel::Serializers::JSON
;TI"
;TI"+ attr_accessor :name, :age, :awesome
;TI"
;TI" def attributes=(hash)
;TI"# hash.each do |key, value|
;TI"" send("#{key}=", value)
;TI"
end
;TI" end
;TI"
;TI" def attributes
;TI" instance_values
;TI" end
;TI" end
;TI"
;TI";json = { name: 'bob', age: 22, awesome:true }.to_json
;TI"person = Person.new
;TI"`person.from_json(json) # => #<Person:0x007fec5e7a0088 @age=22, @awesome=true, @name="bob">
;TI"'person.name # => "bob"
;TI"$person.age # => 22
;TI"&person.awesome # => true
;T:@format0o;
; [I"KThe default value for +include_root+ is +false+. You can change it to ;TI"A+true+ if the given JSON string includes a single root node.;T@o;; [I"Gjson = { person: { name: 'bob', age: 22, awesome:true } }.to_json
;TI"person = Person.new
;TI"fperson.from_json(json, true) # => #<Person:0x007fec5e7a0088 @age=22, @awesome=true, @name="bob">
;TI"-person.name # => "bob"
;TI"*person.age # => 22
;TI"+person.awesome # => true;T;
0:
@fileI")lib/active_model/serializers/json.rb;T:0@omit_headings_from_table_of_contents_below000[ I"0(json, include_root = include_root_in_json);T@3FI" JSON;TcRDoc::NormalModule00