module MsRest::JSONable

Mixin to provide simple serialization / deserialization in AutoRest generated model classes

Public Instance Methods

from_json(json, mapper = nil) click to toggle source

Deserialize the object from JSON @param json [String] JSON string representation of the object @return [JSONable] object built from json input

# File lib/ms_rest/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) click to toggle source

Serialize the object to JSON @param options [Hash] hash map contains options to convert to json. @return [String] JSON serialized version of the object

# File lib/ms_rest/jsonable.rb, line 15
def to_json(options = nil)
  mapper = (options.nil? || !options.key?(:mapper))? self.class.mapper: options[:mapper]
  object = (options.nil? || !options.key?(:object))? self: options[:object]
  serialize(mapper, object)
end
to_s() click to toggle source

String representation of the object @return [String]

# File lib/ms_rest/jsonable.rb, line 35
def to_s
  "#{super} #{to_json.to_s}"
end