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
I have a problem, when i want exclude sertain fields from serialization. I can provide use case, that helps understand the problem: we have 3-rd party REST API, with PATCH method for updating entities.
For example, User class look like this:
So, we dont want to update "last_name" field, but we get it in serialization output. We can clean up nulls from resulting array, but then we loose ability to send nulls and we need it, because in other situation, we might want to "clear" our "last_name" by sending null value to that API. I faced this problem in my project and didnt find good solution.
The way i see it, is something like NullObjects, wich can mark fields, that excluded from serialization of some instance. (closed PR with my implementation)
In previous case, User class would look like this:
I have a problem, when i want exclude sertain fields from serialization. I can provide use case, that helps understand the problem: we have 3-rd party REST API, with PATCH method for updating entities.
For example, User class look like this:
If we want to update just first name without knowing last name, we make something like
And it serializes in array:
So, we dont want to update "last_name" field, but we get it in serialization output. We can clean up nulls from resulting array, but then we loose ability to send nulls and we need it, because in other situation, we might want to "clear" our "last_name" by sending null value to that API. I faced this problem in my project and didnt find good solution.
The way i see it, is something like NullObjects, wich can mark fields, that excluded from serialization of some instance. (closed PR with my implementation)
In previous case, User class would look like this:
When we want to update just "first_name":
And it serializes in array:
I hope i provided enough information to understand the issue.
The text was updated successfully, but these errors were encountered: