我将工作所在的API代码更新为FastJson(https://github.com/Netflix/fast_jsonapi)。 “旧”代码正在使用activeModel并具有
activeModel::Serializer::CollectionSerializer.new
。我不知道如何将该代码“转换”为FastJson API。
我已经在FastJson文档中搜索了有关集合序列化(https://github.com/Netflix/fast_jsonapi#collection-serialization)的信息,但是我不理解该示例。
class API::Messages::MessagesSerializer < activeModel::Serializer
attributes :id,:name,:description
attribute :chats do
activeModel::Serializer::CollectionSerializer.new(
object.user_chats,serializer: API:Messages::ChatUserSerializer
)
end
end