You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there a way to exclude attributes if its value is nil?
We're are migrating our API serialization library to yours, particularly because of performance reasons. And we have multiple instances of big payloads where there are fields that could be nil.
For example, this is how we include errors on our serializers, which leads us to instances where if the resource has no errors it will include it in the payload unnecessarily.
class ApplicationSerializer < Panko::Serializer
attributes :errors
def errors
return unless object&.errors&.any?
object.errors.messages
end
end
If it's not possible at the moment, is this a feature that you might consider adding support for in the future? For example a general config where you could skip all nil values.
The text was updated successfully, but these errors were encountered:
Hi! sorry for the late reply @yosiat , but that Panko::SKIP option should be enough to help us!
I think it might be worth adding a reference on that feature to your documentation!
Cheers!
Similar to #133
Is there a way to exclude attributes if its value is nil?
We're are migrating our API serialization library to yours, particularly because of performance reasons. And we have multiple instances of big payloads where there are fields that could be nil.
For example, this is how we include errors on our serializers, which leads us to instances where if the resource has no errors it will include it in the payload unnecessarily.
If it's not possible at the moment, is this a feature that you might consider adding support for in the future? For example a general config where you could skip all nil values.
The text was updated successfully, but these errors were encountered: