本文整理汇总了Java中org.zalando.jackson.datatype.money.MoneyModule类的典型用法代码示例。如果您正苦于以下问题:Java MoneyModule类的具体用法?Java MoneyModule怎么用?Java MoneyModule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MoneyModule类属于org.zalando.jackson.datatype.money包,在下文中一共展示了MoneyModule类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: postProcessAfterInitialization
import org.zalando.jackson.datatype.money.MoneyModule; //导入依赖的package包/类
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
if (!(bean instanceof ObjectMapper)) {
return bean;
}
ObjectMapper mapper = (ObjectMapper) bean;
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
mapper.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, false);
mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false);
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
registerQuantitySerializer(mapper);
mapper.registerModules(new MoneyModule(), new JavaTimeModule(), new Jackson2HalModule());
return mapper;
}
示例2: build
import org.zalando.jackson.datatype.money.MoneyModule; //导入依赖的package包/类
public ObjectMapper build() {
ObjectMapper mapper = new ObjectMapper();
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
mapper.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, false);
mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false);
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
registerQuantitySerializer(mapper);
mapper.registerModules(new MoneyModule(), new JavaTimeModule(), new Jackson2HalModule());
return mapper;
}
示例3: objectMapper
import org.zalando.jackson.datatype.money.MoneyModule; //导入依赖的package包/类
@Bean
public ObjectMapper objectMapper() {
Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
builder.featuresToDisable(
SerializationFeature.WRITE_DATES_AS_TIMESTAMPS
);
builder.featuresToEnable(
SerializationFeature.WRITE_DATES_WITH_ZONE_ID,
// SerializationFeature.WRITE_DATES_AS_TIMESTAMPS,
// SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS,
// DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS,
DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT
);
builder.indentOutput(true);
builder.failOnEmptyBeans(false);
builder.failOnUnknownProperties(false);
// do not include null value in json to make object graph smaller
builder.serializationInclusion(JsonInclude.Include.NON_NULL);
builder.modules(new GeoJsonModule(), new JavaTimeModule(), new MoneyModule());
return builder.build();
}
示例4: customObjectMapper
import org.zalando.jackson.datatype.money.MoneyModule; //导入依赖的package包/类
@Bean(name = "customObjectMapper")
public ObjectMapper customObjectMapper() {
Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
builder.featuresToDisable(
SerializationFeature.WRITE_DATES_AS_TIMESTAMPS
);
builder.featuresToEnable(
SerializationFeature.WRITE_DATES_WITH_ZONE_ID,
// SerializationFeature.WRITE_DATES_AS_TIMESTAMPS,
// SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS,
// DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS,
DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT
);
builder.indentOutput(true);
builder.failOnEmptyBeans(false);
builder.failOnUnknownProperties(false);
// do not include null value in json to make object graph smaller
builder.serializationInclusion(JsonInclude.Include.NON_NULL);
builder.modules(new GeoJsonModule(), new JavaTimeModule(), new MoneyModule());
return builder.build();
}
示例5: main
import org.zalando.jackson.datatype.money.MoneyModule; //导入依赖的package包/类
public static void main(String[] args) throws IOException, InterruptedException {
final ObjectMapper objectMapper = new ObjectMapper();
objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
objectMapper.disable(MapperFeature.DEFAULT_VIEW_INCLUSION);
objectMapper.registerModule(new JavaTimeModule());
objectMapper.registerModule(new Jdk8Module());
objectMapper.registerModule(new MoneyModule());
objectMapper.registerModule(new ParameterNamesModule());
final Listener<SalesOrderPlaced> listener = events -> {
if (Math.random() < 0.0000001) {
// For testing reconnection logic
throw new EventProcessingException("Random failure");
} else {
for (SalesOrderPlaced salesOrderPlaced : events) {
final SalesOrder order = salesOrderPlaced.getSalesOrder();
LOG.info("Received sales order [{}] created at [{}]", order.getOrderNumber(), order.getCreatedAt());
}
}
};
//subscriptionListen(objectMapper, listener);
subscriptionListenHttpComponents(objectMapper, listener);
//subscriptionListenSpringAdapter(objectMapper, listener);
//subscriptionListenWithPositionCursors(objectMapper, listener);
//subscriptionMultipleEvents(objectMapper);
//simpleListen(objectMapper, listener);
//persistentListen(objectMapper, listener);
//multiInstanceListen(objectMapper, listener);
}
示例6: moneyModule
import org.zalando.jackson.datatype.money.MoneyModule; //导入依赖的package包/类
@Bean
public Module moneyModule() {
return new MoneyModule();
}