version:jackson 2.7.0

public static void main(String[] args) throws JsonProcessingException {
        TestData testData1 = new TestData();
        testData1.setId("1");
        testData1.setName("11");
        testData1.setValue("111");
        TestData testData2 = new TestData();
        testData2.setId("2");
        testData2.setName("22");
        testData2.setValue("222");

        List<TestData> list = new ArrayList<TestData>();
        list.add(testData1);
        list.add(testData2);

        ObjectMapper mapper = new ObjectMapper();
        SimpleFilterProvider filters = new SimpleFilterProvider();
        
filters.addFilter("testFilter",SimpleBeanPropertyFilter.filterOutAllExcept(new 
String[]{"name"}));
//      
filters.addFilter("testFilter",SimpleBeanPropertyFilter.serializeAllExcept(new 
String[] {"name"}));
        mapper.setFilterProvider(filters);

        String s = mapper.writeValueAsString(list);
        System.out.println(s);
    }

output is 
[{"id":"1","name":"11","value":"111"},{"id":"2","name":"22","value":"222"}]
but i want 
[{"id":"1","value":"111"},{"id":"2",,"value":"222"}]
and I don't want to use annotations.

Can you tell me how to sovle it?

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to