Linked Questions
12 questions linked to/from Jackson Change JsonIgnore Dynamically
152 votes
18 answers
439k views
Ignore fields from Java object dynamically while sending as JSON from Spring MVC
I have model class like this, for hibernate @Entity @Table(name = "user", catalog = "userdb") @JsonIgnoreProperties(ignoreUnknown = true) public class User implements java.io.Serializable { ...
73 votes
3 answers
39k views
How to serialize only the ID of a child with Jackson
Is there a built-in way to only serialize the id of a child when using Jackson (fasterxml.jackson 2.1.1)? We want to send an Order via REST which has a Person reference. The person object however is ...
21 votes
3 answers
18k views
How to dynamically ignore a property on Jackson serialization
I have an entity with multiple @ManyToOne associations. I am using spring-boot to expose a REST API. Currently, I have multiple REST API's which return a JSON response of the whole entity, including ...
1 vote
4 answers
20k views
How to filter attributes from JSON response in spring?
I have a controller like the following, @RequestMapping(value = "rest/v1/tester") public class TestController { @RequestMapping(value = "/search", method = RequestMethod.GET) public ...
2 votes
3 answers
9k views
Jackson JSON Ignore Properties Dynamically
I have the following classes - Employee public class Employee { private String firstName ; private String lastName ; private String emailAddress ; private String ssn ; } Payroll ...
3 votes
3 answers
3k views
JAVA JACKSON: serialize a class with two field instead of all class
I need to serialize an entity with only two column when it's called by a foreign key. I'am working in Wildfly, so I'am searching for a jackson solutions. Suppose I have entity class A public class A{...
1 vote
3 answers
2k views
How to get Entity from RestController depending on mapping URL
I have MyEntity class: @Entity @Table("entities) public class MyEntity { @ID private String name; @Column(name="age") private int age; @Column(name="weight") private ...
0 votes
4 answers
3k views
Exclude some field from object while return
I have object that have attributes id, name, description. In some case i want to return whole object but in some i want to return only id, suppose when I insert new record it should only return id ...
3 votes
2 answers
814 views
Jackson only interface field deserialization
Is it possible to deserialize only fields from interface public interface B { String getB(); } public interface A { String getA(); } public class Impl implements A, B { @Override ...
0 votes
1 answer
1k views
How to dynamically avoid sending response containing all properties from relationship data
I am new to spring boot and rest and hence pardon me if this question is very trivial. I have a situation where the application allows users to register and place order. On registration of user, the ...
0 votes
1 answer
811 views
Returning different Resource type Lists from one method
I have this method for a GET request with a parameter embedded. The main idea is if the link contains ?embedded=true it returns the entity and if it's not true then it returns a DTO object: @...
0 votes
0 answers
757 views
SpringMVC: How to filter a JSON-Response dynamically and selectively?
I need to exclude fields before a JSON response is sent, depending on the logged in user. Concretely I have [user]s belonging to [company]s. If the logged-in-user is an administor, he/she should be ...