Problem/Motivation
JSON produced by the HAL and JSON normalizers provides all data values as strings. This makes it difficult for strongly typed uses of the REST interface to interact with the JSON payload. Examples include: client libraries, auto-generated documentation, and schemas. By providing BooleanItem
s as booleans, IntegerItem
s as integers, and so on, the values output in JSON will have the correct type without client-side casting. This has the nice side effect of better lining up output with expectations of the Typed Data API.
Proposed resolution
Add additional field item normalizers casting values to explicitly match the type implied by the field item class.
Remaining tasks
None.
User interface changes
None.
API changes
None: this is an opt-in change. Existing sites continue to get the exact same responses, with booleans and integers as strings.
Only new sites will get the "correct" output by default.
See the change record: https://www.drupal.org/node/2837696.
Data model changes
None.