request.env.to_hash.to_json breaking

Hi,

I've been on this for a bit now trying to find out why this breaks but
I can't. Hopefully someone else will have some idea.

I've been compiling a hash of which one of the objects is request.env.
I then call #to_json on the hash but it fails with:

"You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.pop"

Calling #to_json on request.env.to_hash also fails with error "stack
level too deep".

From the backtrace you can see a loop of the following happening:

/Library/Ruby/Gems/1.8/gems/activesupport-2.3.3/lib/active_support/
json/encoding.rb:69:in `encode'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.3/lib/active_support/
json/encoding.rb:19:in `__send__'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.3/lib/active_support/
json/encoding.rb:19:in `encode'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.3/lib/active_support/
json/encoders/hash.rb:38:in `to_json'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.3/lib/action_view/
renderable.rb:77:in `map'

Anyone have any thoughts on this?

Thanks