Method: Jsoning.generate

Defined in:
lib/jsoning.rb

.generate(object, options = {}) ⇒ Object

generate the json document options:

  • hash: specify if the return is a hash

  • pretty: only for when hash is set to flash, print JSON pretty

  • version: specify the version to be used for the processing



50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/jsoning.rb', line 50

def generate(object, options = {})
  Jsoning.initialize_type_extensions
  protocol = protocol_for!(object.class)

  # use default version if version is unspecified 
  options[:version] = :default if options[:version].nil?

  if options[:hash] == true
    return generate_hash(object, protocol, options)
  else
    return generate_json(object, protocol, options)
  end
end