I have the following simple class:
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
@JsonIgnoreProperties({ \"thirdField\" })
public class Message
You've mixed different versions of Jackson.
Notice that you import JsonIgnoreProperties
from org.codehaus.jackson.annotate
(version 1.x)
while you're using ObjectMapper
from com.fasterxml.jackson.databind
(version 2.x).
I found a Solution to this. Try to add
@JsonSerialize(include= JsonSerialize.Inclusion.NON_EMPTY)
About your class
@JsonSerialize(include= JsonSerialize.Inclusion.NON_EMPTY)
class ResponseModel {
//your properties here
@JsonIgnoreProperties("messageList","contactList","sender")
var contactList= ArrayList<ContactModel>()
}
That will solve your issue buddy.
It didn't work for me any of the above answers, i found a workaround that I have reinitialized the object and values (copied the object).
Try using the last Jackson version (2.4):
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
@JsonIgnoreProperties({"id"})
Here you can find an example where it's implement using version 2.4: http://www.ibm.com/developerworks/java/library/j-hangman-app/index.html