本文整理汇总了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);
}
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}