How not to serialize some attributes in Restful calls with Jersey and Jackson

Asked

Viewed 1,114 times

2

I’m using the Jersey library in conjunction with the Jackson library to use REST-like web services. In calls, I usually use the following code that transforms a particular entity into a JSON to be sent in the request body.

Map<String, Object> response = api.request().post(Entity.json(entidade), Map.class);

The point is that there are some attributes in entidade to be sent that I wish were not serialized as JSON in the request and were absent from it.

Is there any annotation or something of the kind in which it is possible to determine attributes that should not be serialized in this type of request?

1 answer

1


To ignore an attribute in serialization, I used Annotation org.codehaus.jackson.annotate.JsonIgnore of the Jackson library itself. It should be placed in the attribute to be ignored as the following example:

@JsonIgnore
private MeuObjeto objeto;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.