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
I tried deserializing a compound json api document with the gem and found out this isn't supported as of now. For example, if the payload looks like this
One would have to manually to iterate over the data key and feed each resource into the Article deserializer.
class DeserializableArticle < JSONAPI::Deserializable::Resource
has_one :author
has_many :comments do | link, ids, types | do
....
end
end
doc = JSON.parse(document)
doc["data"].map do |resource|
DeserializableArticle.call(resource)
end
But going this way would mean other top level document related resources(the included key) wouldn't be available in the has_many block defined in the deserializer.
Is there a way to get the related resources added in the included top-level part of the document into the has_many/has_one block so we can easily get all the needed data deserialized together?
The text was updated successfully, but these errors were encountered:
@poteto Thanks for your response. I've checked out the working branch and that would work for a single resource. What I'm really looking for is when data is an array of resources. how we can deserialize those resources with the included resources.
Hi
I tried deserializing a compound json api document with the gem and found out this isn't supported as of now. For example, if the payload looks like this
One would have to manually to iterate over the
data
key and feed each resource into the Article deserializer.But going this way would mean other top level document related resources(the
included
key) wouldn't be available in thehas_many
block defined in the deserializer.Is there a way to get the related resources added in the
included
top-level part of the document into thehas_many/has_one
block so we can easily get all the needed data deserialized together?The text was updated successfully, but these errors were encountered: