# Using arbitrary strings for keys in the params hash

**URL:** <https://www.ruby-forum.com/t/using-arbitrary-strings-for-keys-in-the-params-hash/109054>\
**Category:** Rails\
**Created:** [July 11, 2007, 1:02am UTC](https://www.ruby-forum.com/t/using-arbitrary-strings-for-keys-in-the-params-hash/109054 "2007-07-11T01:02:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![matt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a6a055/32.png) [@matt](https://www.ruby-forum.com/u/matt)\
**Post date:** [July 11, 2007, 1:02am UTC](https://www.ruby-forum.com/t/using-arbitrary-strings-for-keys-in-the-params-hash/109054/1 "2007-07-11T01:02:25Z")

</div>

Hi,  
Is there any way to construct a GET or POST request so that the  
resulting params hash can incorporate arbitrary strings (i.e.  
including ampersands, quotes, square brackets…) as its keys? I’m  
trying to do something like

to get back a params hash like

{“translations”=\>{  
“Hello”=\>“Bonjour”,  
“Press [OK] to continue”=\>“Touchez [OK] pour continuer”  
}}

but the square brackets in the second field name cause it to be  
omitted from the hash. I’ve tried escaping them with slashes, URL-  
encoding and everything else I can think of, but it makes no  
difference.

I guess one workaround would be to roll my own encoding scheme  
(something like URL encoding but not quite…) and explicitly decode  
the names at the other end, but it would be nice to be able to avoid  
that step. Any suggestions?

---

<div class="post-metadata">

**Author:** ![matt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a6a055/32.png) [@matt](https://www.ruby-forum.com/u/matt)\
**Post date:** [July 11, 2007, 10:25am UTC](https://www.ruby-forum.com/t/using-arbitrary-strings-for-keys-in-the-params-hash/109054/2 "2007-07-11T10:25:09Z")

</div>

On Jul 11, 1:01 am, Matthew W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’m trying to do something like

Never mind… it occurred to me shortly after posting that I was being  
needlessly ‘cute’ with the params hash there, and would be far better  
off refactoring slightly:

along with

@translations = {}  
for entry in params[:translations]  
@translations[entry[‘original’]] = entry[‘translation’]  
end
