How to implement jsonapi for recursive data


#1

I have two resources, Campaign and Profile. These two resources have many2many relationships.
When I get a Campaign resource, I will get the Profile resources of that Campaign, and I will get the Campaign resources of the previously obtained Profiles.
So how do I display data to properly standard JSON APIs and avoid recursion.


#2

When presenting the default shape of your data, you have the design freedom to cap the arbitrary depth of any recursive or cyclical references.

However, {json:api} removes the redundancies in the included section, which will allows you to cleanly understand, short circuit and serialize the representations with same level references to prevent infinite document depth.

You could also provide a depth filter query parameter to allow the consumer to tailor their request, within the defined limits of the services configuration.