This is the behavior of the built-in
DatetimeCast. It's not particularly critical for me, I added a new
ExtDatetimeCast
Perhaps it is worth adding a special exception for dates in the Entity?
toArray() executes
castAs() and therefore the JSON gets not a string, but an object
PHP Code:
/**
* Support for json_encode()
*
* @return array
*/
#[ReturnTypeWillChange]
public function jsonSerialize()
{
return $this->toArray();
}