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.

@JsonIgnoreProperties should support nested properties

See original GitHub issue

Is your feature request related to a problem? Please describe. It seems that there is no easy way to use the @JsonIgnoreProperties for nested properties. A similar case was #690 but it seems there is no way to do it with annotation.

Describe the solution you’d like Allowing a syntax with dots to go down a level with @JsonIgnoreProperties.

Usage example

class A {
	
	int id;
	
	double value;
	
}

class B {
	
	String name;
	
	A anObject;
	
}

class C {
	
	@JsonIgnoreProperties({ "anObject.id" })
	List<B> aList;
	
}

Would produce a JSON like:

{
	"aList": [
		{
			"name": "...",
			"anObject": {
				"value": 42.0
			},
		},
		{
			"name": "...",
			"anObject": {
				"value": 42.0
			}
		}
	]
}

Additional context This will especially useful for JPA entities with bi-directional mapping, where you can directly return the instance without copying to model to filter some values.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
cowtowncodercommented, Dec 4, 2020

No plans to ever implement this (due to delegating design, will not be possible with current Jackson architecture), closing.

0reactions
Caceresenzocommented, Nov 15, 2020

@JsonFilter only allow you to do it programmatically.

I was looking for an anwser that yould be useful coupled with Spring MVC.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jackson @JsonIgnoreProperties targeting nested attributes
In this example, I want that subAttributeC is not included in the serialization of a ParentObject - but this same subAttributeC still need...
Read more >
Mapping Nested Values with Jackson - Baeldung
This tutorial will demonstrate how to handle inclusion of subtype metadata and ignoring properties inherited from superclasses with Jackson.
Read more >
Developers - @JsonIgnoreProperties should support nested ...
JsonIgnoreProperties should support nested properties. ... It seems that there is no easy way to use the @JsonIgnoreProperties for nested properties.
Read more >
Unrecognized field, not marked as ignorable - JSON Parsing ...
Alternatively, you can also use @JsonIgnoreProperties annotation to ignore undeclared properties. The @JsonIgnoreProperties is a class-level annotation in ...
Read more >
Ignore property of object in list property of a class
What I want to have is a field level annotation as such. · This is so as to prevent recursion based on the...
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