Netflix / fast_jsonapi

No Longer Maintained - A lightning fast JSON:API serializer for Ruby Objects.
Apache License 2.0
5.07k stars 425 forks source link

#serialized_json for empty collection #466

Open jji-fieldwire opened 4 years ago

jji-fieldwire commented 4 years ago

Hi,

Behavior for serializer passed empty collection is to return nil

I think it would make more sense for the serializer to return []. Ideally would work with empty Array and empty Relation.

##### Current behavior
UserSerializer.new([]).serialized_json
=> nil

##### Desired behavior(?)
UserSerializer.new(User.where.not(id: nil)).serialized_json
=> "[]"
davidwparker commented 3 years ago

https://github.com/Netflix/fast_jsonapi/issues/462