Skip to content

Conversation

viralpraxis
Copy link
Contributor

I've seen this pattern a lot:

JSON.parse(large_json).deep_symbolize_keys

instead of travesing Ruby hash once more we can use the symbolize_names option:

JSON.parse(large_json, symbolize_names: true)

Caveats / FP scenarios:

  1. symbolize_names does not work if create_addition option is provided.
  2. User might use both symbolize_names: false and deep_symbolize_keys.
  3. There's no autocorrection yet, but it should be relatively easy to add (at least for some cases)

Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.

I've seen this pattern a lot:

```ruby
JSON.parse(large_json).deep_symbolize_keys
```

instead of travesing Ruby hash once more we can use the `symbolize_names` option:

```ruby
JSON.parse(large_json, symbolize_names: true)
```

Caveats / FP scenarios:
1. `symbolize_names` does not work if `create_addition` option is provided.
2. User might use both `symbolize_names: false` and `deep_symbolize_keys`.
3. There's no autocorrection yet, but it should be easy to add.
@viralpraxis viralpraxis force-pushed the add-new-rails-json-symbolize-names-cop branch from 5d3d3cd to d75d110 Compare September 23, 2025 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant