# File lib/json/common.rb, line 214
  def pretty_generate(obj, opts = nil)
    state = JSON.state.new(
      :indent     => '  ',
      :space      => ' ',
      :object_nl  => "\n",
      :array_nl   => "\n",
      :check_circular => true
    )
    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.configure(opts)
    end
    obj.to_json(state)
  end