# Clarification on nested resources in included array

**URL:** <https://discuss.jsonapi.org/t/clarification-on-nested-resources-in-included-array/1215>\
**Category:** Uncategorized\
**Created:** [February 23, 2018, 4:45pm UTC](https://discuss.jsonapi.org/t/clarification-on-nested-resources-in-included-array/1215 "2018-02-23T16:45:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mvilrokx](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.jsonapi.org/mvilrokx/32/526_2.png) [@mvilrokx](https://discuss.jsonapi.org/u/mvilrokx)\
**Post date:** [February 23, 2018, 4:45pm UTC](https://discuss.jsonapi.org/t/clarification-on-nested-resources-in-included-array/1215/1 "2018-02-23T16:45:18Z")

</div>

I have a DB schema that has a few 1-n relationships, lets say a User has many Orders which has many Order Lines:

```
users ----< orders ---< order_lines

```

I’ve implemented the include parameter on my APIs so a client can request all of this data in one go like this:

```
/users/1?include=orders.order_lines

```

From what a gather from the specs, I understand that I need to put both `orders` and `order_lines` in the `included` section of the API response.

It also seems that they need to appear on the same level, i.e. both `orders` and `order_lines` go into the `includes` array as equals.

**My questions are:**

1. Am I understanding this correctly?
2. If so, why is this represented as a flat structure? Why isn’t `order_lines` nested inside `orders` (maybe as another `includes`?)

---

<div class="post-metadata">

**Author:** ![michaelhibay](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.jsonapi.org/michaelhibay/32/405_2.png) [@michaelhibay](https://discuss.jsonapi.org/u/michaelhibay)\
**Post date:** [February 25, 2018, 3:31pm UTC](https://discuss.jsonapi.org/t/clarification-on-nested-resources-in-included-array/1215/2 "2018-02-25T15:31:52Z")

</div>

Yes, I believe you are understanding this correctly. The reason this is done is because each type / id pair should only appear a single time, and the array is simply a bucket to hold the references for the resources and the identifier objects for full linkage. Nothing in the includes section is structurally significant, and all _should_ be the flattened representation of each resource.

I hope that helps!
