# Composite attributes in a resource object

**URL:** <https://discuss.jsonapi.org/t/composite-attributes-in-a-resource-object/2016>\
**Category:** Uncategorized\
**Created:** [August 4, 2020, 9:37pm UTC](https://discuss.jsonapi.org/t/composite-attributes-in-a-resource-object/2016 "2020-08-04T21:37:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![aklahoty](https://avatars.discourse-cdn.com/v4/letter/a/d26b3c/32.png) [@aklahoty](https://discuss.jsonapi.org/u/aklahoty)\
**Post date:** [August 4, 2020, 9:37pm UTC](https://discuss.jsonapi.org/t/composite-attributes-in-a-resource-object/2016/1 "2020-08-04T21:37:40Z")

</div>

Hi,  
I have the following json schema defined.  
},  
“data”: {  
“id”: “12345”,  
“type”: “Employee”,  
“attributes”: {  
“ssn”: “string”,  
“name”: {  
“title”: “string”,  
“firstName”: “string”,  
“middleName”: “string”,  
“lastName”: “string”,  
“metadata”: {  
“startDate”: “2020-08-04”,  
“endDate”: “2020-08-04”  
}  
},  
“alternateName”: {  
“title”: “string”,  
“firstName”: “string”,  
“middleNames”: “string”,  
“lastName”: “string”,  
“metadata”: {  
“startDate”: “2020-08-04”,  
“endDate”: “2020-08-04”  
}  
},  
“contactDetails”: {  
“homeTelephoneNumber”: “string”,  
“emailAddress”: “string”,  
“preferredContactMethod”: “home\_telephone\_number”  
“metadata”: {  
“startDate”: “2020-08-04”,  
“endDate”: “2020-08-04”  
}  
}

}  
}  
}

Is it a best practice to have the attributes defined as composites?  
Note I do not have relationships requirement and all attributes are for the type ‘Employee’.

If I need to implement sparse fieldset, which of the following will be the right query. My requirement is that I need to give clients the ability to either extract the entire name field or any specific attribute(s) within the name field.

a.  
/api/employee?fields[employee]=ssn,name.title,contactDetails  
b.  
/api/employee?fields[employee]=ssn,fields[employee]=name.title,fields[employee]=contactDetails  
c.  
/api/employee?fields[name]=title,fields[contactDetails]  
d.  
/api/employee?fields[name]=title,fields[contactDetails]=metadata.startDate
