Motivation
This module enhances the REST export functionality in Views to solve the following use cases:
- Your field has multiple values. You want to render each item, but export them as an array instead of a single string.
- Your field contains data that is a JSON primitive (ie. a boolean or number). You want to export this value as the correct type, instead of a string.
- Your field is an entity reference. You want to export the target entity as a nested object, instead of a single string.
Architecture
The reason this utility can be necessary is due to Drupal core's views being tightly coupled with the render system, which implicitly assumes that it is working with HTML output. A REST view display uses this same system to gather and process data, and then passes the render array to a serializer instead of rendering it to HTML.
In order to export rich data without turning it into strings, this module uses a trick: It provides a custom views field handler that returns an object which the render system considers a "Markup" object, but which will be turned back into data when passed to the JSON serializer.
Usage
After installing this module, each entity field can be accessed in Views
via a new handler named "Field (Serializable)".
This field handler automatically exports multiple-value fields as arrays.
This is dependent on the cardinality in the schema, so it will be applied
even if the field contains less than two actual values.
Furthermore, several field types will have new field formatters designed
to export non-string values, including:
- Boolean
- Numeric
- Entity Reference
- Entity Reference Revisions
- Image
Note that these will only work in combination with the Serializable handlers.
Project information
- Project categories: Developer tools, Import and export
3,812 sites report using this module
- Created by cburschka on , updated
Stable releases for this project are covered by the security advisory policy.
Look for the shield icon below.

