jbuilder
jbuilder copied to clipboard
ignore camelizing key when using key_format!
Is there a way to ignore certain keys from being camelized with jbuilder?
json.key_format! camelize: :lower
There is no inbuilt feature for that, but we can do something like this to achieve the same.
json.key_format! ->(key){ [KEY_TO_IGNORE].include?(key.to_sym) ? key : key.camelize(:lower) }
@rakeshpatra that is actually an important missing piece from the docs; those who haven't read directly in the code may never know it's there
that you can pass a "callable" (proc/lambda) I mean