本文整理汇总了Java中com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter.serializeAllExcept方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleBeanPropertyFilter.serializeAllExcept方法的具体用法?Java SimpleBeanPropertyFilter.serializeAllExcept怎么用?Java SimpleBeanPropertyFilter.serializeAllExcept使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter
的用法示例。
在下文中一共展示了SimpleBeanPropertyFilter.serializeAllExcept方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
SomeObject someObject = new SomeObject(1, 2, 3);
PropertyFilter withoutB = SimpleBeanPropertyFilter.serializeAllExcept("b");
String actual = mapper.writeValueAsString(someObject);
Assert.assertEquals(1, parser.parse(actual).read("$.a", Integer.class).intValue());
Assert.assertEquals(2, parser.parse(actual).read("$.b", Integer.class).intValue());
Assert.assertEquals(3, parser.parse(actual).read("$.c", Integer.class).intValue());
actual = mapper.writer(new DynamicFilterProvider(withoutB)).writeValueAsString(someObject);
Assert.assertEquals(1, parser.parse(actual).read("$.a", Integer.class).intValue());
Assert.assertNull(parser.parse(actual).read("$.b"));
Assert.assertEquals(3, parser.parse(actual).read("$.c", Integer.class).intValue());
actual = mapper.writeValueAsString(someObject);
Assert.assertEquals(1, parser.parse(actual).read("$.a", Integer.class).intValue());
Assert.assertEquals(2, parser.parse(actual).read("$.b", Integer.class).intValue());
Assert.assertEquals(3, parser.parse(actual).read("$.c", Integer.class).intValue());
actual = mapper.writer(new DynamicFilterProvider()).writeValueAsString(someObject);
Assert.assertEquals(1, parser.parse(actual).read("$.a", Integer.class).intValue());
Assert.assertEquals(2, parser.parse(actual).read("$.b", Integer.class).intValue());
Assert.assertEquals(3, parser.parse(actual).read("$.c", Integer.class).intValue());
}
示例2: ensureThatSerializingASymbolWithoutProjectDoesNotCrash
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; //导入方法依赖的package包/类
@Test
public void ensureThatSerializingASymbolWithoutProjectDoesNotCrash() throws JsonProcessingException {
String expectedJson = "{\"actions\":["
+ "{\"type\":\"web_click\",\"disabled\":false,\"negated\":false,\"ignoreFailure\":false,"
+ "\"errorOutput\":null,\"node\":null,\"doubleClick\":false},"
+ "{\"type\":\"web_checkForText\",\"disabled\":false,\"negated\":false,\"ignoreFailure\":false,"
+ "\"errorOutput\":null,\"value\":\"F[oO0]+\",\"regexp\":true},"
+ "{\"type\":\"wait\",\"disabled\":false,\"negated\":false,\"ignoreFailure\":false,"
+ "\"errorOutput\":null,\"duration\":" + ONE_SECOND + "}"
+ "],\"group\":2,\"id\":null,\"name\":\"WebSymbol\",\"project\":null,\"successOutput\":null}";
symbol.setProject(null);
ObjectMapper mapper = new ObjectMapper();
mapper.addMixInAnnotations(Object.class, PropertyFilterMixIn.class);
SimpleBeanPropertyFilter filter = SimpleBeanPropertyFilter.serializeAllExcept("hidden");
FilterProvider filters = new SimpleFilterProvider().addFilter("filter properties by name", filter);
String json = mapper.writer(filters).writeValueAsString(symbol);
assertEquals(expectedJson, json);
}
示例3: objectToJsonExclude
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; //导入方法依赖的package包/类
public static String objectToJsonExclude(Object data,String filterName, String ...exName) {
try {
SimpleBeanPropertyFilter theFilter = SimpleBeanPropertyFilter
.serializeAllExcept(exName);
FilterProvider filters = new SimpleFilterProvider()
.addFilter(filterName, theFilter);
return MAPPER.writer(filters).writeValueAsString(data);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
return null;
}
示例4: ObjectMapperExceptField
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; //导入方法依赖的package包/类
public ObjectMapperExceptField(Class<?> targetClass, String property) {
super();
SimpleBeanPropertyFilter theFilter = SimpleBeanPropertyFilter.serializeAllExcept(property);
FilterProvider filters = new SimpleFilterProvider().addFilter("myFilter", theFilter);
addMixInAnnotations(targetClass, PropertyFilterMixIn.class);
setFilters(filters);
}
示例5: writeGroup
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; //导入方法依赖的package包/类
public static String writeGroup(SymbolGroup group) throws JsonProcessingException {
SimpleBeanPropertyFilter filter = SimpleBeanPropertyFilter.serializeAllExcept("symbolAmount");
FilterProvider filters = new SimpleFilterProvider().addFilter("filter properties by name", filter);
ObjectMapper mapper = new ObjectMapper();
mapper.addMixInAnnotations(Object.class, PropertyFilterMixIn.class);
return mapper.writer(filters).writeValueAsString(group);
}
示例6: modify
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; //导入方法依赖的package包/类
@Override
public ObjectWriter modify(EndpointConfigBase<?> endpoint, MultivaluedMap<String, Object> responseHeaders, Object valueToWrite,
ObjectWriter w, JsonGenerator g) throws IOException {
SimpleBeanPropertyFilter filter = null;
if (includes != null && !includes.isEmpty()) {
filter = new SimpleBeanPropertyFilter.FilterExceptFilter(includes);
} else if (excludes != null && !excludes.isEmpty()) {
filter = SimpleBeanPropertyFilter.serializeAllExcept(excludes);
} else {
filter = SimpleBeanPropertyFilter.serializeAllExcept(new HashSet<String>());
}
FilterProvider provider = new SimpleFilterProvider().addFilter("property_filter", filter);
return w.with(provider);
}
示例7: getCustomFilterProvider
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; //导入方法依赖的package包/类
public static SimpleFilterProvider getCustomFilterProvider() {
SimpleFilterProvider filterProvider = new SimpleFilterProvider();
for (Map.Entry<Class<? extends HistoryEvent>, Class> mixInFilter : getDefaultMixInFilters().entrySet()) {
String jsonFilterId = getJsonFilterAnnotationValue(mixInFilter.getValue());
if (jsonFilterId != null) {
SimpleBeanPropertyFilter filter = SimpleBeanPropertyFilter.serializeAllExcept("");
// TODO: add extension mechanism to declare filter values via ElasticSearchHistoryPluginConfiguration
filterProvider.addFilter(jsonFilterId, filter);
}
}
return filterProvider;
}
示例8: apply
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; //导入方法依赖的package包/类
@Override
public PropertyFilter apply(SerializeAllExcept annotation) {
return SimpleBeanPropertyFilter.serializeAllExcept(annotation.value());
}
示例9: exclude
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; //导入方法依赖的package包/类
/**
* 排除指定的属性
*/
public Jacksons exclude(Class<?> dataType, String... properties) {
SimpleBeanPropertyFilter filter = SimpleBeanPropertyFilter.serializeAllExcept(properties);
return definePropertyFilter(dataType, filter);
}