File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -1727,6 +1727,23 @@ hash.exclude?(:key)
17271727string.exclude?('substring')
17281728----
17291729
1730+ === `deep_symbolize_keys` [[deep-symbolize-keys]]
1731+
1732+ Prefer JSON's `symbolize_names` keyword argument instead of chaining `deep_symbolize_keys`.
1733+
1734+ Using `symbolize_names: true` is more efficient as it creates symbols during parsing
1735+ rather than requiring a second pass through the data structure.
1736+
1737+ [source,ruby]
1738+ ----
1739+ # bad
1740+ JSON.parse(data).deep_symbolize_keys
1741+ JSON.parse(data).deep_transform_keys(&:to_sym)
1742+
1743+ # good
1744+ JSON.parse(data, symbolize_names: true)
1745+ ----
1746+
17301747=== Prefer using squiggly heredoc over `strip_heredoc` [[prefer-squiggly-heredoc]]
17311748
17321749If you're using Ruby 2.3 or higher, prefer squiggly heredoc (`<<~`) over Active Support's `strip_heredoc`.
You can’t perform that action at this time.
0 commit comments