当前位置: 首页>>代码示例>>Java>>正文


Java SimpleBeanPropertyFilter.serializeAllExcept方法代码示例

本文整理汇总了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());
}
 
开发者ID:shihyuho,项目名称:jackson-dynamic-filter,代码行数:26,代码来源:DynamicFilterProviderTest.java

示例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);
}
 
开发者ID:LearnLib,项目名称:alex,代码行数:23,代码来源:WebSymbolTest.java

示例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;
  }
 
开发者ID:mmdsyl,项目名称:BLOG-Microservice,代码行数:14,代码来源:JsonUtils.java

示例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);
}
 
开发者ID:bonitasoft,项目名称:bonita-ui-designer,代码行数:8,代码来源:ObjectMapperExceptField.java

示例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);
}
 
开发者ID:LearnLib,项目名称:alex,代码行数:8,代码来源:SymbolGroupResourceTest.java

示例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);
}
 
开发者ID:minnal,项目名称:minnal,代码行数:15,代码来源:ResponseTransformationFilter.java

示例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;
}
 
开发者ID:camunda,项目名称:camunda-bpm-elasticsearch,代码行数:14,代码来源:JacksonMixInFilterModule.java

示例8: apply

import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; //导入方法依赖的package包/类
@Override
public PropertyFilter apply(SerializeAllExcept annotation) {
  return SimpleBeanPropertyFilter.serializeAllExcept(annotation.value());
}
 
开发者ID:shihyuho,项目名称:jackson-dynamic-filter,代码行数:5,代码来源:SerializeAllExceptResolver.java

示例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);
   }
 
开发者ID:easycodebox,项目名称:easycode,代码行数:8,代码来源:Jacksons.java


注:本文中的com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter.serializeAllExcept方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。