Module: MsRest2::JSONable
- Includes:
- Serialization
- Defined in:
- lib/ms_rest2/jsonable.rb
Overview
Mixin to provide simple serialization / deserialization in AutoRest generated model classes
Instance Method Summary collapse
-
#from_json(json, mapper = nil) ⇒ JSONable
Deserialize the object from JSON.
-
#to_json(options = nil) ⇒ String
Serialize the object to JSON.
-
#to_s ⇒ String
String representation of the object.
Methods included from Serialization
Instance Method Details
#from_json(json, mapper = nil) ⇒ JSONable
Deserialize the object from JSON
26 27 28 29 |
# File 'lib/ms_rest2/jsonable.rb', line 26 def from_json(json, mapper = nil) mapper = self.class.mapper if mapper.nil? deserialize(mapper, json) end |
#to_json(options = nil) ⇒ String
Serialize the object to JSON
15 16 17 18 19 |
# File 'lib/ms_rest2/jsonable.rb', line 15 def to_json( = nil) mapper = (.nil? || !.key?(:mapper))? self.class.mapper: [:mapper] object = (.nil? || !.key?(:object))? self: [:object] serialize(mapper, object) end |
#to_s ⇒ String
String representation of the object
35 36 37 |
# File 'lib/ms_rest2/jsonable.rb', line 35 def to_s "#{super} #{to_json.to_s}" end |