Converting nested hash keys from CamelCase to snake_case in Ruby

后端 未结 6 434
一生所求
一生所求 2020-12-30 20:21

I\'m trying to build an API wrapper gem, and having issues with converting hash keys to a more Rubyish format from the JSON the API returns.

The JSON contains multip

6条回答
  •  醉梦人生
    2020-12-30 21:00

    The accepted answer by 'mu is too short' has been converted into a gem, futurechimp's Plissken:

    https://github.com/futurechimp/plissken/blob/master/lib/plissken/ext/hash/to_snake_keys.rb

    This looks like it should work outside of Rails as the underscore functionality is included.

提交回复
热议问题