Skip to content
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

Omit null valued properties when deserializing POJOs #29

Closed
joelittlejohn opened this issue Jun 23, 2013 · 1 comment
Closed

Omit null valued properties when deserializing POJOs #29

joelittlejohn opened this issue Jun 23, 2013 · 1 comment

Comments

@joelittlejohn
Copy link
Owner

Original author: [email protected] (June 09, 2011 20:58:16)

It's typical to use JSON as a minimal/lightweight serialization format. Usually, for the sake of brevity, a good signal/noise ratio, and sematic correctness, properties which don't have a value are omitted rather than present with a null value.

e.g.

{ "id" : "5652963" }

is preferred over

{ "id" : "5652963", "name" : null }

By default, Jackson includes null valued properties in serialized output but this can easily be changed using @JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL).

I believe this annotation should be used by default, my guess is that most JSON users prefer the lighter/cleaner format. If required, I'll add a parameter to allow this to be removed though, for those that want to see the nulls.

Original issue: http://code.google.com/p/jsonschema2pojo/issues/detail?id=29

@joelittlejohn
Copy link
Owner Author

From [email protected] on June 09, 2011 22:22:27
Fixed in rd815c9e46fb7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant