Reputation: 19120
I'm using Rails 4.2. I noticed when I try and create an array of hashes, it seems my string keys are getting converted to symbols ...
> my_hash_arr = [{"name": "DA", "amount": 100000 }]
=> [{:name=>"DA", :amount=>100000}]
I don't want this. I want my key "name", to remain as a string and not be converted to a symbol key. How do I structure my array so this conversion doesn't take place.
Upvotes: 3
Views: 1241
Reputation: 1168
If you want that, the correct syntax is changing :
to =>
like this:
my_hash_arr = [{"name" => "DA", "amount" => 100000 }]
=> [{"name"=>"DA", "amount"=>100000}]
Upvotes: 4