配置内置Jackson MapDeserializer

时间:2016-06-29 10:50:28

标签: java spring jackson

我有一个带有spring mvc的项目,我想调用方法" setIgnorableProperties"从MapDeserializer全局,但我不知道如何从ObjectMapper获取此类,你能帮助我吗?感谢您的建议。  我看到了,就像那样:

@Override
public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
    mapDeserializer.getContentType();
    converters.forEach(httpMessageConverter -> {
        if (httpMessageConverter instanceof MappingJackson2HttpMessageConverter) {
            MappingJackson2HttpMessageConverter converter = (MappingJackson2HttpMessageConverter) httpMessageConverter;
            ObjectMapper mapper = converter.getObjectMapper();
            MapDeserializer mapDes = mapper.(What I have to invoke?) ;
            mapDes.setIgnorableProperties({"@id", "@ref"});
        }
    });
}

1 个答案:

答案 0 :(得分:1)

该属性不是直接配置的;您需要对from cycler import cycler my_cycle = (cycler('lw', [1, 3] * cycler('color', ['b', 'g', 'r', 'c', 'm', 'y', 'k'])) fig, ax = plt.subplots() for sty, data in zip(my_cycle(), my_data): ax.plot(x, data, **sty) - 值属性使用@JsonIgnoreProperties注释。 如果需要,您可以通过以下方式创建便利注释:

Map

然后使用like:

@Retention(RetentionPolicy.RUNTIME) // IMPORTANT
@JacksonAnnotationsInside
@JsonIgnoreProperties({ "@id", "@ref" })
public @interface MapIgnorals