-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow passing instance method or conditional expressions to option ignore_serialize
on JSON::Field
#11804
Allow passing instance method or conditional expressions to option ignore_serialize
on JSON::Field
#11804
Conversation
ignore_serialize_if
on JSON::Field
ignore_serialize_if
on JSON::Field
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
@cyangle Was it not possible to make existing |
Great idea, let me see if I could make it backward compatible or not. |
…nore_deserialize It is backwards compatible when set to `true`
In last commit, I implemented what @vlazar suggested. It works and should be backward compatible. I don't like the nested |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At first I thought having two separate fields would be better. But I see it's probably a good idea to merge them.
I just have a few comments to simplify the implementation.
ignore_serialize_if
on JSON::Field
ignore_serialize
on JSON::Field
@straight-shoota Could this PR be merged before the 1.4 release? |
We need another approval for this. @beta-ziliani maybe? |
Closes #11803
Allow passing instance method or conditional expressions to option ignore_serialize on JSON::Field from #11803.
It seems to be trivial to implement since the compiler and stdlib are written in crystal itself.
The new specs provide example usages: