question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add `@JsonIncludeProperties(propertyNames)` (reverse of `@JsonIgnoreProperties`)

See original GitHub issue

In some/many cases it’d be easier to just name properties to include, reverse of @JsonIgnoreProperties. And similarly, it should be possible to define baselines by type as well as property overrides; and if ever we support inheritance-merging in class hierarchy, use similar merging strategies (merge vs replace).

NOTE: for this (2.12.0) implementation, no merging exists for class annotations – sub-class definitions will always simply replace super-class/super-interface definitions. Similarly there is no way to specify inclusions using “ConfigOverride” system, although ignoral is possible. Latter would likely be relatively easy to implement (so feel free to file a follow-up request); former (annotation merging) is a more difficult ask (but likewise feel free to file a feature request).

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:90
  • Comments:33 (9 by maintainers)

github_iconTop GitHub Comments

6reactions
sunphycommented, Apr 2, 2018

Yes,@JsonIncludeProperties(propertyNames) is very useful!

4reactions
ssamayoacommented, Oct 1, 2018

I also need @JsonIncludeProperties(propertyNames) Not only for sensitive fields but also for complex entity objects in which normally you don’t need other than few properties, example:

@Entity
public class Customer {
...
private SalesMan salesMan;
...
@ManyToOne
@JsonIncludeProperties({"id", "name"})
public SalesMan getSalesMan() {
  return salesMan;
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Security update for jackson-databind, jackson-dataformats ...
An update that fixes three vulnerabilities is now available. Description: This update for jackson-databind, jackson-dataformats-binary, ...
Read more >
Jackson Annotations: Difference Between ... - Stack Overflow
Short answer: @JsonIgnoreProperties(ignoreUnknown=true) is applicable at deserialization of JSON to Java object ( POJO ) only. If your POJO does not contain ...
Read more >
JacksonAnnotationIntrospector (jackson-databind 2.13.0 API)
Method called to check whether given property is marked to be "unwrapped" when being serialized (and appropriately handled in reverse direction, i.e..
Read more >
Using @JsonIgnore and @JsonIgnoreProperties to ignore ...
Ignoring Unknown Properties. @JsonIgnoreProperties#ignoreUnknown can be used to ignore a JSON property if is not defined in the POJO: @ ...
Read more >
JsonIgnoreProperties (Jackson-annotations 2.12.0 API)
Annotation can be applied both to classes and to properties. If used for both, actual set will be union of all ignorals: that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found