Low commit activity in last 3 years
A long-lived project that still receives updates
Convert nested data structure hash keys between camel and snake case.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

camel_snake_keys

[![Gem Version][GV img]][Gem Version] [Gem Version]: https://rubygems.org/gems/camel_snake_keys

Add recursive with_snake_keys and with_camel_keys refinements to Array and Hash. Preserve strings and symbols and treat hash descendents such as ActiveSupport::HashWithIndifferentAccess and Hashie::Mash agnostically.

Documentation

Add gem 'camel_snake_keys' to your Gemfile or "gem install camel_snake_keys".

Where you want to add with_snake_keys and with_camel_keys to your objects invoke using CamelSnakeKeys, or invoke the class methods, CamelSnakeKeys.camel_keys(object) and CamelSnakeKeys.snake_keys(object).

require 'camel_snake_keys'

using CamelSnakeKeys

{fooBar: "Frob"}.with_snake_keys
=> {:foo_bar=>"Frob"}

[{:foo_bar=>"Frob"}].with_camel_keys
=> [{fooBar: "Frob"}]