You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the navigator determines an item should be excluded, it returns null for that value. This works as expected if setSerialiseNull is false, however when it's true, the item gets included with a null value.
As this will now change behaviour, it may be desirable to include a configuration parameter (eg setIncludeExcludedAsNull()) to enable this new behaviour, defaulting to on. However I consider this behaviour to be a bug and is inconsistent with the behaviour when setSerialiseNull is set to false so I don't think this is required
The text was updated successfully, but these errors were encountered:
Steps required to reproduce the problem
Expected Result
Actual Result
Details
The issue occurs here:
https://github.com/schmittjoh/serializer/blob/master/src/JMS/Serializer/GenericSerializationVisitor.php#L111
When the navigator determines an item should be excluded, it returns null for that value. This works as expected if setSerialiseNull is false, however when it's true, the item gets included with a null value.
Solution
The solution here is to have the navigator throw an UnacceptableException (https://github.com/schmittjoh/serializer/blob/master/src/JMS/Serializer/GraphNavigator.php#L225) when it encounters a field which should not be included in the result. That can then be caught in the code linked above and handled eg excluded from the result.
BC preservation
As this will now change behaviour, it may be desirable to include a configuration parameter (eg setIncludeExcludedAsNull()) to enable this new behaviour, defaulting to on. However I consider this behaviour to be a bug and is inconsistent with the behaviour when setSerialiseNull is set to false so I don't think this is required
The text was updated successfully, but these errors were encountered: