Problem/Motivation

When using Smart Date with JSON:API (e.g. via Entity Share), SmartDateNormalizer::denormalize() returns the full Smart Date field structure during per-property denormalization.

FieldItemNormalizer expects each property (value, end_value, duration, etc.) to be denormalized independently, but SmartDateNormalizer returns an array of all properties, causing data nesting and unexpected structures.

Example of the resulting $data_internal from FieldItemNormalizer:

array (
  'value' => 
  array (
    'value' => 1760029200,
    'end_value' => NULL,
    'duration' => NULL,
    'rrule' => NULL,
    'rrule_index' => NULL,
    'timezone' => NULL,
  ),
  'end_value' => 
  array (
    'value' => 1760032800,
    'end_value' => NULL,
    'duration' => NULL,
    'rrule' => NULL,
    'rrule_index' => NULL,
    'timezone' => NULL,
  ),
  'duration' => 60,
  'rrule' => NULL,
  'rrule_index' => NULL,
  'timezone' => '',
)

Cause

FieldItemNormalizer calls denormalizers on each property individually.

SmartDateNormalizer::denormalize() assumes it always receives the full SmartDate object and builds an array of all properties.

This mismatch leads to nested/duplicated data.

Proposed Solution

Update SmartDateNormalizer::denormalize() to detect when it is receiving:

A scalar/NULL value (per-property denormalization) → delegate to TimestampNormalizer.

An array/object (whole SmartDate item) → build and return the full property array.

Will have a merge request in soon.

Full Disclosure

I originally reported this at the Entity Share queue - you can see a full write up there. Assistance with this write up care of ChatGPT.

Issue fork smart_date-3544983

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

pbabin created an issue.