Skip to content

Option to omit empty fields #26

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

Merged
merged 4 commits into from
Jul 25, 2017
Merged

Option to omit empty fields #26

merged 4 commits into from
Jul 25, 2017

Conversation

kevmoo
Copy link
Collaborator

@kevmoo kevmoo commented Jul 25, 2017

No description provided.

@kevmoo kevmoo force-pushed the omit_empty_fields branch from 6ee1c16 to e488748 Compare July 25, 2017 01:24
@kevmoo kevmoo force-pushed the omit_empty_fields branch from b248b44 to 7c131ad Compare July 25, 2017 16:10
@kevmoo kevmoo changed the title WIP: Omit empty fields Option to omit empty fields Jul 25, 2017
@kevmoo kevmoo requested a review from natebosch July 25, 2017 16:11
const JsonSerializable({bool createFactory: true, bool createToJson: true})
: this.createFactory = createFactory,
this.createToJson = createToJson;
/// [true] if the generator should include the this field in the serialized
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] 'Whether the generator should...'

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

const JsonSerializable(
{bool createFactory: true,
bool createToJson: true,
bool includeIfNull: true})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is true the default? Backwards compatibility?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. It can also lead to some weirdness – like having a completely empty Map returned from toJson – better to make it opt-in.

Also the code generated is a lot uglier.

@kevmoo kevmoo force-pushed the omit_empty_fields branch from 7c131ad to 86098bc Compare July 25, 2017 17:19
@kevmoo kevmoo merged commit 86098bc into master Jul 25, 2017
@kevmoo kevmoo deleted the omit_empty_fields branch July 25, 2017 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants