Closed pke closed 7 years ago
I don't believe there's an automatic way, but it should be possible with one of Hashie extensions and some wrapper code. Please contribute!
@pke - AMS has support for this via the key_transform option
You can specify this options globally:
ActiveModelSerializers.config.key_transform = :camel_lower
Up until this pull request, however, you were not able to specify this for specific render actions because grape-ASM did not pass that option through. If you want it for a specific render action, you can point your Gemfile to:
gem 'grape-active_model_serializers',
github: 'ruby-grape/grape-active_model_serializers',
branch: 'pass-ams-options'
and specify the key_transform
option explicitly, like:
render user, key_transform: :camel_lower
Let me know if that solves it for you
When returning JSON it does make no sense to expose the non-JSON ruby like variable naming scheme, imho. Is there a way to configure the serializer to convert the key names to proper json key names?