Skip to content

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

Closed as not planned

Description

@tilo

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}

Activity

  1. trans commented on Oct 1, 2016

    @trans
    Member

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

  2. ioquatix commented on Oct 13, 2016

    @ioquatix
    Contributor

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

  3. ioquatix commented on Mar 9, 2017

    @ioquatix
    Contributor

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

  4. added this to the 4.0.0 milestone on Mar 9, 2017
  5. trans commented on Nov 2, 2026

    @trans
    Member

    This matches ActiveSupport, where symbolize_keys/stringify_keys are also shallow; in Facets 4.0 they live in lib/rails. For nested hashes use h.recurse(&:symbolize_keys) or h.recurse(&:rekey).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions