本文整理匯總了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();
}