Crell / Serde

Robust Serde (serialization/deserialization) library for PHP 8.
Other
299 stars 14 forks source link

Deserializing NULL values is ignored #53

Closed waahhhh closed 7 months ago

waahhhh commented 9 months ago

Detailed description

Provide a detailed description of the change or addition you are proposing.

Make it clear if the issue is a bug, an enhancement or just a question.

Currently there is a bug that prevents nullable properties from being explicitly set to NULL.
If you use #[ClassSettings(requireValues: true)], you will receive a Crell\Serde\MissingRequiredValueWhenDeserializing error.

Context

Why is this change important to you? How would you use it?

Serde is used to map the raw data of a JSON API into an object.
It's necessary to be able to pass certain values as NULL.

How can it benefit other users?

This behavior is surely expected for other users.

Possible implementation

Not obligatory, but suggest an idea for implementing addition or change.

Passing an existing value as NULL should result in setting the property to NULL.

Your environment

Include as many relevant details about the environment you experienced the bug in and how to reproduce it.

Crell commented 9 months ago

Can you provide a PR with a failing tests that I can work from?

waahhhh commented 9 months ago

Creating the PR takes some time, because it's not easy for me to find into the project. Now I've found an approach. The PR will be ready shortly.