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


Java ObjectMapper.addMixIn方法代码示例

本文整理汇总了Java中com.fasterxml.jackson.databind.ObjectMapper.addMixIn方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectMapper.addMixIn方法的具体用法?Java ObjectMapper.addMixIn怎么用?Java ObjectMapper.addMixIn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.fasterxml.jackson.databind.ObjectMapper的用法示例。


在下文中一共展示了ObjectMapper.addMixIn方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initializeObjectMapper

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@Override
protected ObjectMapper initializeObjectMapper() {
    final ObjectMapper mapper = super.initializeObjectMapper();

    final FilterProvider filters = new SimpleFilterProvider()
            .addFilter("beanObjectFilter", new CasSimpleBeanObjectFilter());
    mapper.setFilters(filters);

    mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
    mapper.configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, false);
    mapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);
    mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
    mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    mapper.addMixIn(Object.class, CasSimpleBeanObjectFilter.class);
    mapper.disable(SerializationFeature.INDENT_OUTPUT);
    mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);

    return mapper;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:20,代码来源:InternalConfigStateController.java

示例2: getAppStatusList

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@JsonIgnore
public List<AppStatus> getAppStatusList() {
	try {
		ObjectMapper mapper = new ObjectMapper();
		mapper.addMixIn(AppStatus.class, AppStatusMixin.class);
		mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
		SimpleModule module = new SimpleModule("CustomModel", Version.unknownVersion());
		SimpleAbstractTypeResolver resolver = new SimpleAbstractTypeResolver();
		resolver.addMapping(AppInstanceStatus.class, AppInstanceStatusImpl.class);
		module.setAbstractTypes(resolver);
		mapper.registerModule(module);
		TypeReference<List<AppStatus>> typeRef = new TypeReference<List<AppStatus>>() {
		};
		if (this.platformStatus != null) {
			return mapper.readValue(this.platformStatus, typeRef);
		}
		return new ArrayList<AppStatus>();
	}
	catch (Exception e) {
		throw new IllegalArgumentException("Could not parse Skipper Platfrom Status JSON:" + platformStatus, e);
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-skipper,代码行数:23,代码来源:Status.java

示例3: createMapper

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
private ObjectMapper createMapper(JsonFactory mapping, ClassLoader classLoader) {
    ObjectMapper mapper = new ObjectMapper(mapping);
    mapper.addMixIn(MasterSlaveServersConfig.class, MasterSlaveServersConfigMixIn.class);
    mapper.addMixIn(SingleServerConfig.class, SingleSeverConfigMixIn.class);
    mapper.addMixIn(Config.class, ConfigMixIn.class);
    mapper.addMixIn(CodecProvider.class, ClassMixIn.class);
    mapper.addMixIn(ResolverProvider.class, ClassMixIn.class);
    mapper.addMixIn(Codec.class, ClassMixIn.class);
    mapper.addMixIn(RedissonNodeInitializer.class, ClassMixIn.class);
    mapper.addMixIn(LoadBalancer.class, ClassMixIn.class);
    FilterProvider filterProvider = new SimpleFilterProvider()
            .addFilter("classFilter", SimpleBeanPropertyFilter.filterOutAllExcept());
    mapper.setFilterProvider(filterProvider);
    mapper.setSerializationInclusion(Include.NON_NULL);

    if (classLoader != null) {
        TypeFactory tf = TypeFactory.defaultInstance()
                .withClassLoader(classLoader);
        mapper.setTypeFactory(tf);
    }
    
    return mapper;
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:24,代码来源:ConfigSupport.java

示例4: init

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
protected void init(ObjectMapper objectMapper) {
    objectMapper.registerModule(new DefenceModule());
    
    objectMapper.setSerializationInclusion(Include.NON_NULL);
    objectMapper.setVisibilityChecker(objectMapper.getSerializationConfig().getDefaultVisibilityChecker()
            .withFieldVisibility(JsonAutoDetect.Visibility.ANY).withGetterVisibility(JsonAutoDetect.Visibility.NONE)
            .withSetterVisibility(JsonAutoDetect.Visibility.NONE)
            .withCreatorVisibility(JsonAutoDetect.Visibility.NONE));
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    objectMapper.configure(SerializationFeature.WRITE_BIGDECIMAL_AS_PLAIN, true);
    objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
    objectMapper.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true);
    objectMapper.addMixIn(Throwable.class, ThrowableMixIn.class);
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:15,代码来源:JsonJacksonCodec.java

示例5: repositoryPopulator

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
/**
 * Read JSON data from disk and insert those stores.
 * 
 * @return
 */
public @Bean AbstractRepositoryPopulatorFactoryBean repositoryPopulator() {

	ObjectMapper mapper = new ObjectMapper();
	mapper.addMixIn(GeoJsonPoint.class, GeoJsonPointMixin.class);
	mapper.configure(FAIL_ON_UNKNOWN_PROPERTIES, false);

	Jackson2RepositoryPopulatorFactoryBean factoryBean = new Jackson2RepositoryPopulatorFactoryBean();
	factoryBean.setResources(new Resource[] { new ClassPathResource("starbucks-in-nyc.json") });
	factoryBean.setMapper(mapper);

	return factoryBean;
}
 
开发者ID:Just-Fun,项目名称:spring-data-examples,代码行数:18,代码来源:ApplicationConfiguration.java

示例6: UnwiredGeolocationProvider

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
public UnwiredGeolocationProvider(String url, String key) {
    this.url = url;
    this.key = key;

    objectMapper = new ObjectMapper();
    objectMapper.addMixIn(Network.class, NetworkMixIn.class);
    objectMapper.addMixIn(CellTower.class, CellTowerMixIn.class);
    objectMapper.addMixIn(WifiAccessPoint.class, WifiAccessPointMixIn.class);
}
 
开发者ID:bamartinezd,项目名称:traccar-service,代码行数:10,代码来源:UnwiredGeolocationProvider.java

示例7: configure

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
public static ObjectMapper configure(ObjectMapper objectMapper) {
  objectMapper.addMixIn(Span.class, SpanMixin.class);
  objectMapper.addMixIn(KeyValue.class, KeyValueMixin.class);
  objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
  return objectMapper;
}
 
开发者ID:jaegertracing,项目名称:spark-dependencies,代码行数:7,代码来源:JsonHelper.java

示例8: newObjectMapper

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
protected ObjectMapper newObjectMapper(Configuration configuration, ScanResult scanResult) {
  Boolean property = PropertyHelper.getProperty(configuration, RestServerV2.JSON_PRETTYPRINT_ENABLE);
  final boolean prettyPrint = property != null && property;

  ObjectMapper mapper = prettyPrint ? JSONUtil.prettyMapper() : JSONUtil.mapper();
  JSONUtil.registerStorageTypes(mapper, scanResult);
  mapper.addMixIn(VirtualDatasetUI.class, VirtualDatasetUIMixin.class);

  return mapper;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:11,代码来源:DACJacksonJaxbJsonFeature.java

示例9: initializeObjectMapper

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
/**
 * Mixins are added to the object mapper in order to
 * ignore certain method signatures from serialization
 * that are otherwise treated as getters. Each mixin
 * implements the appropriate interface as a private
 * dummy class and is annotated with JsonIgnore elements
 * throughout. This helps us catch errors at compile-time
 * when the interface changes.
 * @return the prepped object mapper.
 */
@Override
protected ObjectMapper initializeObjectMapper() {
    final ObjectMapper mapper = super.initializeObjectMapper();
    mapper.addMixIn(RegisteredServiceProxyPolicy.class, RegisteredServiceProxyPolicyMixin.class);
    mapper.addMixIn(RegisteredServiceAccessStrategy.class, RegisteredServiceAuthorizationStrategyMixin.class);

    return mapper;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:19,代码来源:RegisteredServiceJsonSerializer.java

示例10: initializeObjectMapper

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
/**
 * Mixins are added to the object mapper in order to
 * ignore certain method signatures from serialization
 * that are otherwise treated as getters. Each mixin
 * implements the appropriate interface as a private
 * dummy class and is annotated with JsonIgnore elements
 * throughout. This helps us catch errors at compile-time
 * when the interface changes.
 * @return the prepped object mapper.
 */
@Override
protected ObjectMapper initializeObjectMapper() {
    final ObjectMapper mapper = super.initializeObjectMapper();
    mapper.addMixIn(RegisteredServiceProxyPolicy.class, RegisteredServiceProxyPolicyMixin.class);
    mapper.addMixIn(RegisteredServiceAccessStrategy.class, RegisteredServiceAuthorizationStrategyMixin.class);
    mapper.addMixIn(Duration.class, DurationMixin.class);
    return mapper;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:19,代码来源:RegisteredServiceJsonSerializer.java

示例11: marshallingWithMixins

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@Test
public void marshallingWithMixins() throws Exception {

    ObjectMapper objectMapper = new ObjectMapper();

    objectMapper.addMixIn(Address.class, AddressMixIn.class);

    String jsonString = objectMapper.writeValueAsString(address);


    assertEquals("{\"nomDeRue\":\"A street name\",\"city\":\"A city\",\"province\":\"A province\",\"postalCode\":\"A postal code\",\"country\":\"A country\"}", jsonString);


}
 
开发者ID:fdlessard,项目名称:EqualsProject,代码行数:15,代码来源:AddressTest.java

示例12: marshallingWithMixins

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@Test
public void marshallingWithMixins() throws Exception {

    ObjectMapper objectMapper = new ObjectMapper();

    objectMapper.addMixIn(ExtendedAddress.class, AddressMixIn.class);

    String jsonString = objectMapper.writeValueAsString(extendedAddress);


    assertEquals("{\"city\":\"A city\",\"province\":\"A province\",\"postalCode\":\"A postal code\",\"country\":\"A country\",\"county\":\"A county\",\"nomDeRue\":\"A street name\"}", jsonString);

}
 
开发者ID:fdlessard,项目名称:EqualsProject,代码行数:14,代码来源:ExtendedAddressTest.java


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