jbuilder icon indicating copy to clipboard operation
jbuilder copied to clipboard

ignore camelizing key when using key_format!

Open kimyu-ng opened this issue 7 years ago • 3 comments

Is there a way to ignore certain keys from being camelized with jbuilder?

json.key_format! camelize: :lower

kimyu-ng avatar Mar 07 '18 20:03 kimyu-ng

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 avatar Jul 28 '20 04:07 rakeshpatra

@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

SampsonCrowley avatar Mar 25 '24 20:03 SampsonCrowley

that you can pass a "callable" (proc/lambda) I mean

SampsonCrowley avatar Mar 25 '24 20:03 SampsonCrowley