JSON Light support in REST SharePoint API
SP1 introduces support for JSON Light, allowing developers to choose which level of metadata they would like in a response: no metadata, minimal metadata, or full metadata.
The REST SharePoint API has been an extremely popular way for SharePoint developers to work with SharePoint sites, lists/libraries, and list items/documents. Over these years, REST SharePoint API had heavy payload of data that was returned. Microsoft SharePoint team's response was to add support for JSON Light. JSON Light is an open standard that allows developers to provide in the header of the request how much metadata is returned. To check out more about JSON Light, head over to the Microsoft OData JSON spec document. You can also check out all the endpoints for the SharePoint REST API over on MSDN.
Before this, when calling the SharePoint REST API, SharePoint developers had to include in the header request : “accept: application/json; odata=verbose”. This header is now optional, and more OData options have been added. If you don’t require all of the metadata for your business solution, you can significantly reduce the payload of your calls by using one of these other options. Take a look at this set of OData examples based on a common scenario of requesting a set of list items from a list and the associated response size.
Option 1: verbose
“accept: application/json; odata=verbose” 46,647 bytes
Option 2: minimalmetadata
“accept: application/json; odata=minimalmetadata” 11,173 bytes
Option 3: nometadata
accept: application/json; odata=nometadata” 6,832 bytes
The nometadata option reduces the size of the payload significantly, and for many scenarios this is all that you need when working with list items, for example.
Option 4: Don’t provide it
“accept: application/json” 11,173 bytes
You are no longer required to provide the OData property in the request header, unless you would like to specify one of the values above. This defaults to minimalmetadata option.