Skip to content

Jackson

wizardjedi edited this page Jun 28, 2014 · 3 revisions

Сериализация с помощью правил (views)

public class JsonViews {
    public static class Public { }
    public static class ExtendedPublic extends Public{ }
    public static class Internal extends ExtendedPublic { }
}
ObjectMapper mapper = originalMapper.copy();

mapper.configure(MapperFeature.DEFAULT_VIEW_INCLUSION, false);

ObjectWriter writerWithView = mapper.writerWithView(JsonViews.Public.class);

return writerWithView.writeValueAsString(object);

Clone this wiki locally