Snippet
@Controller
public class SubjectController
{
private ObjectMapper _objectMapper = new ObjectMapper();
public Controller()
{
_objectMapper.getSerializationConfig().addMixInAnnotations(Base.class, FieldsNotAvailable.class);
}
@RequestMapping(value="/path", method={RequestMethod.GET})
public @ResponseBody String getJson(ModelMap model)
{
return _objectMapper.writeValueAsString(subject);
}
}
public abstract class FiledsNotAvailable
{
@JsonIgnore
public abstract String getSomeField();
}
http://stackoverflow.com/questions/22609079/how-to-filter-the-json-response-returning-from-spring-rest-web-service
http://fasterxml.github.io/jackson-databind/javadoc/2.0.0/com/fasterxml/jackson/databind/ObjectMapper.html#addMixInAnnotations(java.lang.Class, java.lang.Class)
0 件のコメント:
コメントを投稿