當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。