Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any way to automatically camelCase all keys? #12

Open
Fire-Dragon-DoL opened this issue Mar 23, 2017 · 4 comments
Open

Any way to automatically camelCase all keys? #12

Fire-Dragon-DoL opened this issue Mar 23, 2017 · 4 comments

Comments

@Fire-Dragon-DoL
Copy link

Hello! In ruby we use snake_case everywhere and I suffer when I have to camelCase in any place.
Is there any option to camelKeys automatically all keys right before spitting out the JSON?

I would use it so that my JSON api stays consistent with javascript notation

@vassilevsky
Copy link

We are solving this problem in our projects with https://github.com/RSCSCybersecurity/sparrow and it works pretty well.

@frederikspang
Copy link

Or in case you wanna avoid using an extra middleware (Which isn't a bad solution, but some might prefer not to), you could in your builder-files use .camelize(:lower) for the keys, if you're settings the attributes dynamically.

@ksouthworth
Copy link

I agree with @Fire-Dragon-DoL it would be great to have support for automatically camelCasing keys for output.

Something like the olive_branch gem https://github.com/vigetlabs/olive_branch

@andrewclink
Copy link

I was using a MultiJson.use(MyCustomKeyTransformer) to do this, and it worked pretty well. Unfortunately a JB commit in October seems to have broken multi_json support. Multi_json does provide a nice two-way API, though, if the situation is solvable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants