# Should JSON Api attributes element contain nested objects?

**URL:** <https://discuss.jsonapi.org/t/should-json-api-attributes-element-contain-nested-objects/893>\
**Category:** Uncategorized\
**Created:** [January 28, 2017, 10:12pm UTC](https://discuss.jsonapi.org/t/should-json-api-attributes-element-contain-nested-objects/893 "2017-01-28T22:12:49Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![scottmcdonald](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.jsonapi.org/scottmcdonald/32/340_2.png) [@scottmcdonald](https://discuss.jsonapi.org/u/scottmcdonald)\
**Post date:** [January 31, 2017, 9:38pm UTC](https://discuss.jsonapi.org/t/should-json-api-attributes-element-contain-nested-objects/893/6 "2017-01-31T21:38:56Z")

</div>

Yes the specification allows nested complex types in attributes of an individual resource, BUT the complex type can not be another resource. See for example [Clarification on Resources Composed of Other Resources](http://discuss.jsonapi.org/t/clarification-on-resources-composed-of-other-resources/252) in the json:api forum for details on this topic. If the nested type is another resource, favor a relationship instead. A corollary to this is do not include “foreign keys” in resources, again instead favor relationships between resources that abstract foreign keys away.

---

_[View the full topic](https://discuss.jsonapi.org/t/should-json-api-attributes-element-contain-nested-objects/893)._
