Examples of SimpleFilterProvider


Examples of com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider

        mapper.setAnnotationIntrospector(pair);
        mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);

        // Filter specific things we do not want exported:
        SimpleFilterProvider filterProvider = new SimpleFilterProvider();
        filterProvider.setFailOnUnknownId(false);
        filterProvider = filterProvider.addFilter("EntitlementFilter",
            SimpleBeanPropertyFilter.serializeAllExcept("consumer"));
        mapper.setFilters(filterProvider);

        if (config != null) {
            mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,
View Full Code Here

Examples of com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider

   * Configure PropertyFiler to make sure Jackson doesn't process CGLIB generated bean
   * properties.
   */
  private void applyCglibFilters(ObjectMapper mapper) {
    mapper.setAnnotationIntrospector(new CglibAnnotationIntrospector());
    mapper.setFilters(new SimpleFilterProvider().addFilter(CGLIB_FILTER_ID,
        new CglibBeanPropertyFilter()));
  }
View Full Code Here

Examples of com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider

    }

    public void noErrorOnUnknownFilter() {
        // Configure an empty FilterProvider so it will not complain when a filter is not found (such as Couch).
        this.setFilters(new SimpleFilterProvider().setFailOnUnknownId(false));
    }
View Full Code Here

Examples of com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider

    public void testWithJsonFilter() throws Exception
    {
        CsvMapper mapper = mapperForCsv();
        CsvSchema schema = mapper.schemaFor(Company.class).withLineSeparator("\n").withHeader();

        SimpleFilterProvider filterProvider = new SimpleFilterProvider()
                .addFilter(COMPANY_FILTER, FilterExceptFilter.filterOutAllExcept("name", "ticker"));

        List<Company> companies = Arrays.asList(
                new Company(1, "name1", "ticker1")
                , new Company(2, "name2", "ticker2")
View Full Code Here

Examples of com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider

    @Test
    public final void givenTypeHasFilterThatIgnoresFieldByName_whenDtoIsSerialized_thenCorrect() throws JsonParseException, IOException {
        final ObjectMapper mapper = new ObjectMapper();
        final SimpleBeanPropertyFilter theFilter = SimpleBeanPropertyFilter.serializeAllExcept("intValue");
        final FilterProvider filters = new SimpleFilterProvider().addFilter("myFilter", theFilter);

        final MyDtoWithFilter dtoObject = new MyDtoWithFilter();
        dtoObject.setIntValue(12);

        final String dtoAsString = mapper.writer(filters).writeValueAsString(dtoObject);
View Full Code Here

Examples of com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider

            @Override
            protected final boolean include(final PropertyWriter writer) {
                return true;
            }
        };
        final FilterProvider filters = new SimpleFilterProvider().addFilter("myFilter", theFilter);

        final MyDtoWithFilter dtoObject = new MyDtoWithFilter();
        dtoObject.setIntValue(-1);

        final ObjectMapper mapper = new ObjectMapper();
View Full Code Here

Examples of com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider

    public void testIssue44() throws IOException
    {
        String exp = "<Issue44Bean first=\"abc\"><second>13</second></Issue44Bean>";
        Issue44Bean bean = new Issue44Bean();

        FilterProvider prov = new SimpleFilterProvider().addFilter("filter44",
                SimpleBeanPropertyFilter.serializeAllExcept("filterMe"));
        ObjectWriter writer = _xmlMapper.writer(prov);

        // as well as with proper filter
        assertEquals(exp, writer.writeValueAsString(bean));
View Full Code Here

Examples of com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider

    }

    public void noErrorOnUnknownFilter() {
        // Configure an empty FilterProvider so it will not complain when a filter is not found (such as Couch).
        this.setFilters(new SimpleFilterProvider().setFailOnUnknownId(false));
    }
View Full Code Here

Examples of org.codehaus.jackson.map.ser.impl.SimpleFilterProvider

  @Override
  public <T> String marshall(T entity) {
    try {
      ObjectMapper objectMapper = new ObjectMapper().setVisibility(JsonMethod.FIELD, Visibility.ANY);
      objectMapper.getSerializationConfig().addMixInAnnotations(Object.class, PropertyFilterMixIn.class);
      SimpleFilterProvider filters = new SimpleFilterProvider();

      List<java.lang.reflect.Field> fields = ClassUtil.getAnnotatedFields(entity, Column.class);
      String[] targetedFieldNames = new String[fields.size()];
      for (int i = 0; i < fields.size(); i++) {
        targetedFieldNames[i] = fields.get(i).getName();
      }

      filters.addFilter("PropertyFilter", SimpleBeanPropertyFilter.filterOutAllExcept(targetedFieldNames));
      ObjectWriter objectWriter = objectMapper.writer(filters);
      String json = objectWriter.writeValueAsString(entity);

      List<java.lang.reflect.Field> referencedEntities = ClassUtil.getAnnotatedFields(entity, Reference.class);
      for (java.lang.reflect.Field field : referencedEntities) {
View Full Code Here

Examples of org.codehaus.jackson.map.ser.impl.SimpleFilterProvider

   
    // should also work for @JsonAnyGetter, as per [JACKSON-516]
    public void testAnyGetterFiltering() throws Exception
    {
        ObjectMapper mapper = new ObjectMapper();
        FilterProvider prov = new SimpleFilterProvider().addFilter("anyFilter",
                SimpleBeanPropertyFilter.filterOutAllExcept("b"));
        assertEquals("{\"a\":\"1\"}", mapper.writer(prov).writeValueAsString(new AnyBean()));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.