Skip to content

Can't get to work with DateTime denormalization #85

Open
@ghostika

Description

@ghostika

I've used previously the 0.1.3 version and wanted to update it to v1. I've done the setup according to the documentation, just that 3 normalizer, but somehow my dateTime is not deserialized.
I've checked it with xdebug and all 3 normalizers are registered and they have the right order.

My json string:

[{"#type": "App\\Entity\\EventSchedule", "endDate": "2020-04-11T00:00:00+02:00", "startDate": "2020-01-07T00:00:00+01:00"}]

EventSchedule

class EventSchedule
{
    /**
     * Start date.
     *
     * @var DateTimeImmutable
     */
    private $startDate;

    /**
     * End date.
     *
     * @var DateTimeImmutable
     */
    private $endDate;
}

Error message:
Failed to denormalize attribute "endDate" value for class "App\Entity\EventSchedule": Expected argument of type "DateTimeImmutable", "string" given at property path "endDate"

I would highly appreciate any help.
I have ApiPlatform installed, but in this request, it's not used. I tried just calling the service in the controller and passing the string to the deserialize event.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions