Search in sources :

Example 1 with SimpleFilterProvider

use of com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider in project photo-picker-plus-android by chute.

the class MediaModel method serializeImageDataModel.

public String serializeImageDataModel() {
    FilterProvider filters = new SimpleFilterProvider().addFilter("imageDataModelFilter", SimpleBeanPropertyFilter.filterOutAllExcept("options", "media"));
    String result = null;
    try {
        result = JsonUtil.getMapper().writer(filters).writeValueAsString(this);
    } catch (JsonProcessingException e) {
        Log.d(TAG, "", e);
    }
    return result;
}
Also used : SimpleFilterProvider(com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) FilterProvider(com.fasterxml.jackson.databind.ser.FilterProvider) SimpleFilterProvider(com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider)

Example 2 with SimpleFilterProvider

use of com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider in project jackson-databind by FasterXML.

the class TestAnyGetterFiltering method testAnyGetterFiltering.

/*
    /**********************************************************
    /* Test methods
    /**********************************************************
     */
public void testAnyGetterFiltering() throws Exception {
    ObjectMapper mapper = new ObjectMapper();
    FilterProvider prov = new SimpleFilterProvider().addFilter("anyFilter", SimpleBeanPropertyFilter.filterOutAllExcept("b"));
    assertEquals("{\"b\":\"2\"}", mapper.writer(prov).writeValueAsString(new AnyBean()));
}
Also used : SimpleFilterProvider(com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) FilterProvider(com.fasterxml.jackson.databind.ser.FilterProvider) SimpleFilterProvider(com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider)

Example 3 with SimpleFilterProvider

use of com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider in project jackson-databind by FasterXML.

the class TestMapFiltering method testMapFilteringWithAnnotations.

// [databind#522]
public void testMapFilteringWithAnnotations() throws Exception {
    FilterProvider prov = new SimpleFilterProvider().addFilter("filterX", new TestMapFilter());
    String json = MAPPER.writer(prov).writeValueAsString(new MapBean());
    // a=1 should become a=2
    assertEquals(aposToQuotes("{'values':{'a':2}}"), json);
    // and then one without annotation as contrast
    json = MAPPER.writer(prov).writeValueAsString(new MapBeanNoOffset());
    assertEquals(aposToQuotes("{'values':{'a':1}}"), json);
}
Also used : SimpleFilterProvider(com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider) SimpleFilterProvider(com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider)

Example 4 with SimpleFilterProvider

use of com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider in project jackson-databind by FasterXML.

the class TestMapFiltering method testMapFilteringViaProps.

public void testMapFilteringViaProps() throws Exception {
    FilterProvider prov = new SimpleFilterProvider().addFilter("filterX", SimpleBeanPropertyFilter.filterOutAllExcept("b"));
    String json = MAPPER.writer(prov).writeValueAsString(new MapBean());
    assertEquals(aposToQuotes("{'values':{'b':5}}"), json);
}
Also used : SimpleFilterProvider(com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider) SimpleFilterProvider(com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider)

Example 5 with SimpleFilterProvider

use of com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider in project jackson-databind by FasterXML.

the class TestMapFiltering method testMapFilteringViaClass.

public void testMapFilteringViaClass() throws Exception {
    FilteredBean bean = new FilteredBean();
    bean.put("a", 4);
    bean.put("b", 3);
    FilterProvider prov = new SimpleFilterProvider().addFilter("filterForMaps", SimpleBeanPropertyFilter.filterOutAllExcept("b"));
    String json = MAPPER.writer(prov).writeValueAsString(bean);
    assertEquals(aposToQuotes("{'b':3}"), json);
}
Also used : SimpleFilterProvider(com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider) SimpleFilterProvider(com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider)

Aggregations

SimpleFilterProvider (com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider)51 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)21 FilterProvider (com.fasterxml.jackson.databind.ser.FilterProvider)17 PropertyFilter (com.fasterxml.jackson.databind.ser.PropertyFilter)12 SimpleBeanPropertyFilter (com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter)11 Test (org.junit.Test)10 ApiPermissionFilter (io.gravitee.management.service.jackson.filter.ApiPermissionFilter)9 Before (org.junit.Before)9 Test (org.junit.jupiter.api.Test)7 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)6 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)4 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)4 HashSet (java.util.HashSet)4 JsonGenerationException (com.fasterxml.jackson.core.JsonGenerationException)3 JacksonAnnotationIntrospector (com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector)3 lombok.val (lombok.val)3 Log4jLogEvent (org.apache.logging.log4j.core.impl.Log4jLogEvent)3 AuthenticationProperties (org.apereo.cas.configuration.model.core.authentication.AuthenticationProperties)3 LdapAuthenticationProperties (org.apereo.cas.configuration.model.support.ldap.LdapAuthenticationProperties)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3