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
This works perfectly. However, I need to achieve a similar structure for associations within the serializer. Specifically, I want the association to include both a data and meta object. Here’s what I’ve tried so far:
Attempt 1
I attempted to include meta directly in the association:
I considered using a field for meta but found it awkward and inconsistent with the expected output structure.
None of these approaches work as intended. The meta field doesn't appear in the rendered JSON for the association, and it doesn't behave like the example in the JSON:API Serializer documentation.
Expected Behavior
For an association, I would like the output to include both data and meta fields, structured as follows:
At the moment, meta data is only available at the root-level of the payload, and any workaround would likely be too cumbersome to reasonably work with.
We'll take a look into this and see if it's something that'd be reasonably straightforward to implement, though.
At the moment, meta data is only available at the root-level of the payload, and any workaround would likely be too cumbersome to reasonably work with.
We'll take a look into this and see if it's something that'd be reasonably straightforward to implement, though.
Thank you for the response. I’m working on some proof of concepts to achieve a flatter response that doesn’t require the JSON:API specification.
One of the points I was questioning was about the data and meta in associations, but most models I’ve seen don’t follow this approach.
Anyway, I’ll keep testing the gem. Thanks again, and if you’d like, you can close the issue.
Is there an existing issue for this?
Describe your question or ask for support
Hi,
I am trying to include both
data
andmeta
objects for an association, similar to how it's done for the main serializer output using.render
.For example, I can use the following code to render categories with a
meta
object:This works perfectly. However, I need to achieve a similar structure for associations within the serializer. Specifically, I want the association to include both a data and meta object. Here’s what I’ve tried so far:
Attempt 1
I attempted to include meta directly in the association:
Attempt 2
I tried to manually structure data and meta:
Attempt 3
I considered using a field for meta but found it awkward and inconsistent with the expected output structure.
None of these approaches work as intended. The meta field doesn't appear in the rendered JSON for the association, and it doesn't behave like the example in the JSON:API Serializer documentation.
Expected Behavior
For an association, I would like the output to include both data and meta fields, structured as follows:
Actual Behavior
The meta object is not included in the rendered association output. Instead, only the data field is rendered.
Questions
Is this feature not supported for associations?
Is there a workaround to achieve this structure for associations?
Thank you in advance
The text was updated successfully, but these errors were encountered: