facets icon indicating copy to clipboard operation
facets copied to clipboard

is:issue is:open Hash symbolize_keys stringify_keys does not work on nested hashes

Open tilo opened this issue 9 years ago • 3 comments

symbolize_keys and stringify_keys does not work on nested hashes:

  > {"this"=>{"is"=>:an, "awful"=>:example}, "very"=>:weird}.symbolize_keys
   => {:this=>{"is"=>:an, "awful"=>:example}, :very=>:weird}

and: > {:this => {:is => :an , :awful => :example}, :very => :weird}.stringify_keys => {"this"=>{:is=>:an, :awful=>:example}, "very"=>:weird}

tilo avatar Jan 21 '16 20:01 tilo

Should they do this? Does ActiveSupport/Rails do this?

trans avatar Oct 01 '16 15:10 trans

Nope, I don't think it should work on nested hashes. Also, {stringify/symbolize}_keys is a code smell.. vote to close this issue.

ioquatix avatar Oct 13 '16 01:10 ioquatix

@tilo can you explain your use case a bit more? Did you know JSON and MsgPack have options to load with symbol keys?

ioquatix avatar Mar 09 '17 12:03 ioquatix