Package com.fasterxml.jackson.databind.ser.impl

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


        HashMap<String, Object> jqReturn = Utils.getJQGridJSON(paths, "paths");
       
        ObjectMapper objectMapper = new ObjectMapper();
        objectMapper.addMixInAnnotations(Object.class, ViewFilters.GetPathFilter.class);
        String[] ignorableFieldNames = { "possibleEndpoints", "enabledEndpoints" };
        FilterProvider filters = new SimpleFilterProvider().addFilter("Filter properties from the PathController GET",
            SimpleBeanPropertyFilter.serializeAllExcept(ignorableFieldNames));
           
        ObjectWriter writer = objectMapper.writer(filters);

        return writer.writeValueAsString(jqReturn);
View Full Code Here


        HashMap<String, Object> jqReturn = Utils.getJQGridJSON(trySelectedRequestPaths, "paths");

        ObjectMapper objectMapper = new ObjectMapper();
        objectMapper.addMixInAnnotations(Object.class, ViewFilters.GetPathFilter.class);
        String[] ignorableFieldNames = { "possibleEndpoints", "enabledEndpoints" };
        FilterProvider filters = new SimpleFilterProvider().addFilter("Filter properties from the PathController GET",
              SimpleBeanPropertyFilter.serializeAllExcept(ignorableFieldNames));
   
        ObjectWriter writer = objectMapper.writer(filters);

        return writer.writeValueAsString(jqReturn);
View Full Code Here

   */
  public JsonRequestLogger()
  {
    mapper = new ObjectMapper();
    mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
    SimpleFilterProvider filters = new SimpleFilterProvider();
    filters.addFilter("default",
      SimpleBeanPropertyFilter.serializeAllExcept("eventTarget", "responseTarget"));
    mapper.setFilters(filters);
    mapper.setAnnotationIntrospector(new FilteredIntrospector());
  }
View Full Code Here

   
    // 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("{\"b\":\"2\"}", mapper.writer(prov).writeValueAsString(new AnyBean()));
    }
View Full Code Here

    final ObjectMapper MAPPER = objectMapper();
   
    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);
    }
View Full Code Here

    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);
    }
View Full Code Here

    }
   
    // [Issue#522]
    public void testMapFilteringWithAnnotations() throws Exception
    {
        FilterProvider prov = new SimpleFilterProvider().addFilter("filterX",
                new MyMapFilter());
        String json = MAPPER.writer(prov).writeValueAsString(new MapBean());
        // a=1 should become a=2
        assertEquals(aposToQuotes("{'values':{'a':2}}"), json);
    }
View Full Code Here

                    "Found registered filter - using instead of default view filter for class:"
                            + src.getClass().getName());
            // throw new
            // Exception("Found registered filter - could not use custom view and custom filter for class:"+
            // src.getClass().getName());
            SimpleFilterProvider filter = (SimpleFilterProvider) this.filters.get(src.getClass()
                    .getName());
            return ser(src, filter);//mapper.writerWithView(src.getClass()).writeValueAsString(src);
        }
        String res = mapper.writerWithView(Object.class).writeValueAsString(src);
        if (cleanCache != null && cleanCache) {
View Full Code Here

                    .warn("Found registered filter - could not use custom view and custom filter for class:"
                            + src.getClass().getName());
            // throw new
            // Exception("Found registered filter - could not use custom view and custom filter for class:"+
            // src.getClass().getName());
            SimpleFilterProvider filter = (SimpleFilterProvider) this.filters.get(src.getClass()
                    .getName());
            return ser(src, filter);
        }

        String res = (type != null)? mapper.writerWithView(type).writeValueAsString(src): mapper.writeValueAsString(src);
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    private <T> FilterProvider checkFilter(FilterContext fc,
            Class rootFilterClass, Class<T> filterClass, String... filterAttr) {
        SimpleFilterProvider filter = new SimpleFilterProvider();
        if (filterAttr != null && filterAttr.length > 0
                && (filterClass == null || !rootFilterClass.equals(filterClass))) {
            // filter attributes in root class
            filter = retrieveFilter(filter, fc, rootFilterClass, filterAttr);
        }
View Full Code Here

TOP

Related Classes of com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider

Copyright © 2018 www.massapicom. 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.