# File lib/json/common.rb, line 198
  def generate(obj, opts = nil)
    if opts
      if opts.respond_to? :to_hash
        opts = opts.to_hash
      elsif opts.respond_to? :to_h
        opts = opts.to_h
      else
        raise TypeError, "can't convert #{opts.class} into Hash"
      end
      state = SAFE_STATE_PROTOTYPE.dup
      state = state.configure(opts)
    else
      state = SAFE_STATE_PROTOTYPE
    end
    state.generate(obj)
  end