-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Serializing an empty array should maintain the root key #1156
Serializing an empty array should maintain the root key #1156
Conversation
82424ce
to
91f1ea2
Compare
Allow an empty array to derive the root key from the serializer name why is the array serialized as an array, but a relationship serialized as a hash arrays with the json adapter now have keys fix rubocop stuff
91f1ea2
to
6fdf461
Compare
def inferred_json_key | ||
serializer = options[:serializer] | ||
return unless serializer | ||
potential_model_name = serializer.name.sub('Serializer', '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
serializer.name.remove('Serializer')
🤷
Let's hold off on merging this till we clarify which arguments, See my comment in the OP's issue: #1153 (comment) |
@bf4 for an empty object (Array, or Hash) - would it matter which serializer vs each_serializer we're using? there isn't really anything to serialize aside from the root key. it would either be
or
|
So, AMS doesn't handle primitives, and when they find their way it, they are passed through as is. ( Specifically, when you're not rendering an object with a defined serializer.) How options are parsed
The upshot of which is that
Aside, the the collection serializer (ArraySerializer) cannot identify a serializer for a resource in its collection, it raises |
that is a fantastic explanation! thanks -- I'll close this PR. |
Relates to: #1153