本文整理汇总了Java中com.fasterxml.jackson.datatype.jsr310.JSR310Module类的典型用法代码示例。如果您正苦于以下问题:Java JSR310Module类的具体用法?Java JSR310Module怎么用?Java JSR310Module使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JSR310Module类属于com.fasterxml.jackson.datatype.jsr310包,在下文中一共展示了JSR310Module类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SiloTemplateResolver
import com.fasterxml.jackson.datatype.jsr310.JSR310Module; //导入依赖的package包/类
public SiloTemplateResolver(Class<T> classType) {
ObjectMapper m = new ObjectMapper();
m.registerModule(new GuavaModule());
m.registerModule(new LogbackModule());
m.registerModule(new GuavaExtrasModule());
m.registerModule(new JodaModule());
m.registerModule(new JSR310Module());
m.registerModule(new AfterburnerModule());
m.registerModule(new FuzzyEnumModule());
m.setPropertyNamingStrategy(new AnnotationSensitivePropertyNamingStrategy());
m.setSubtypeResolver(new DiscoverableSubtypeResolver());
//Setup object mapper to ignore the null properties when serializing the objects
m.setSerializationInclusion(JsonInclude.Include.NON_NULL);
//Lets be nice and allow additional properties by default. Allows for more flexible forward/backward
//compatibility and works well with jackson addtional properties feature for serialization
m.configure(FAIL_ON_UNKNOWN_PROPERTIES, false);
this.classType = classType;
this.mapper = m;
}
示例2: testCache
import com.fasterxml.jackson.datatype.jsr310.JSR310Module; //导入依赖的package包/类
@Test
public void testCache() throws Exception {
String projectId = "02a70003-e864-464e-b62c-e0ede97deb8c";
DeliveryClient client = new DeliveryClient(projectId);
final boolean[] cacheHit = {false};
client.setCacheManager(new CacheManager() {
@Override
public JsonNode resolveRequest(String requestUri, HttpRequestExecutor executor) throws IOException {
Assert.assertEquals("https://deliver.kenticocloud.com/02a70003-e864-464e-b62c-e0ede97deb8c/items/on_roasts", requestUri);
cacheHit[0] = true;
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new JSR310Module());
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
return objectMapper.readValue(this.getClass().getResourceAsStream("SampleContentItem.json"), JsonNode.class);
}
});
ContentItemResponse item = client.getItem("on_roasts");
Assert.assertNotNull(item);
Assert.assertTrue(cacheHit[0]);
}
示例3: initialize
import com.fasterxml.jackson.datatype.jsr310.JSR310Module; //导入依赖的package包/类
@Override
public void initialize(Bootstrap<BlockExplorerConfiguration> bootstrap) {
bootstrap.setConfigurationSourceProvider(
new SubstitutingSourceProvider(bootstrap.getConfigurationSourceProvider(),
new EnvironmentVariableSubstitutor()
)
);
hyperLedgerBundle = new HyperLedgerBundle<BlockExplorerConfiguration>() {
@Override
protected HyperLedgerConfiguration getSupernodeConfiguration(BlockExplorerConfiguration configuration) {
return configuration.getHyperLedger();
}
};
bootstrap.addBundle(hyperLedgerBundle);
bootstrap.getObjectMapper().registerModule(new JSR310Module());
}
示例4: initialize
import com.fasterxml.jackson.datatype.jsr310.JSR310Module; //导入依赖的package包/类
@Override
public void initialize(Bootstrap<BlockExplorerConfiguration> bootstrap) {
bootstrap.setConfigurationSourceProvider(
new SubstitutingSourceProvider(bootstrap.getConfigurationSourceProvider(),
new EnvironmentVariableSubstitutor()
)
);
hyperLedgerBundle = new HyperLedgerBundle<BlockExplorerConfiguration>() {
@Override
protected HyperLedgerConfiguration getSupernodeConfiguration(BlockExplorerConfiguration configuration) {
return configuration.getHyperLedger();
// return configuration.getGRPCConnectedHyperLedger();
}
};
bootstrap.addBundle(hyperLedgerBundle);
bootstrap.getObjectMapper().registerModule(new JSR310Module());
}
示例5: initialize
import com.fasterxml.jackson.datatype.jsr310.JSR310Module; //导入依赖的package包/类
@Override
public void initialize(Bootstrap<AppConfiguration> bootstrap) {
bootstrap.setConfigurationSourceProvider(
new SubstitutingSourceProvider(bootstrap.getConfigurationSourceProvider(),
new EnvironmentVariableSubstitutor()
)
);
/* Configure objectMapper to instantiate immutable configuration correctly */
ObjectMapper objectMapper = bootstrap.getObjectMapper();
objectMapper.registerModule(new JSR310Module());
bootstrap.getObjectMapper()
.setVisibilityChecker(objectMapper.getSerializationConfig().getDefaultVisibilityChecker()
.withFieldVisibility(JsonAutoDetect.Visibility.ANY)
.withGetterVisibility(JsonAutoDetect.Visibility.NONE)
.withSetterVisibility(JsonAutoDetect.Visibility.NONE)
.withCreatorVisibility(JsonAutoDetect.Visibility.NONE));
/* Host static resources */
bootstrap.addBundle((new AssetsBundle("/assets", "/", "index.html", "static")));
/* Enable WebSockets support */
bootstrap.addBundle(websocketBundle = new WebsocketBundle<>());
}
示例6: ObjectMapperProvider
import com.fasterxml.jackson.datatype.jsr310.JSR310Module; //导入依赖的package包/类
@Autowired
public ObjectMapperProvider(final JacksonProperties properties,
final JsonSerializer<RichBoolean> richBooleanSerialzer) {
final ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(NON_EMPTY);
mapper.configure(FAIL_ON_UNKNOWN_PROPERTIES, false);
properties.getSerialization().entrySet().forEach(e ->
mapper.configure(e.getKey(), properties.getSerialization().get(e.getKey())));
properties.getDeserialization().entrySet().forEach(e ->
mapper.configure(e.getKey(), properties.getDeserialization().get(e.getKey())));
final SimpleModule customSerializersModule = new SimpleModule();
customSerializersModule.addSerializer(richBooleanSerialzer);
mapper.registerModules(
customSerializersModule,
new Jdk8Module(),
new JSR310Module()
);
this.mapper = mapper;
}
示例7: reconfigureDeserializer
import com.fasterxml.jackson.datatype.jsr310.JSR310Module; //导入依赖的package包/类
private void reconfigureDeserializer() {
objectMapper = new ObjectMapper();
SimpleModule module = new SimpleModule();
objectMapper.registerModule(new JSR310Module());
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
objectMapper.registerModule(module);
}
示例8: newObjectMapper
import com.fasterxml.jackson.datatype.jsr310.JSR310Module; //导入依赖的package包/类
public static ObjectMapper newObjectMapper()
{
// TODO: guice -> io.airlift.json
// seriously
ObjectMapper objectMapper = new ObjectMapper();
// ignore unknown fields (for backwards compatibility)
objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
// use ISO dates
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
// skip fields that are null instead of writing an explicit json null value
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
// disable auto detection of json properties... all properties must be explicit
objectMapper.disable(MapperFeature.AUTO_DETECT_CREATORS);
objectMapper.disable(MapperFeature.AUTO_DETECT_FIELDS);
objectMapper.disable(MapperFeature.AUTO_DETECT_SETTERS);
objectMapper.disable(MapperFeature.AUTO_DETECT_GETTERS);
objectMapper.disable(MapperFeature.AUTO_DETECT_IS_GETTERS);
objectMapper.disable(MapperFeature.USE_GETTERS_AS_SETTERS);
objectMapper.disable(MapperFeature.CAN_OVERRIDE_ACCESS_MODIFIERS);
objectMapper.disable(MapperFeature.INFER_PROPERTY_MUTATORS);
objectMapper.disable(MapperFeature.ALLOW_FINAL_FIELDS_AS_MUTATORS);
objectMapper.registerModules(
new Jdk7Module(),
new Jdk8Module(),
new JSR310Module(),
new GuavaModule(),
new JodaModule());
return objectMapper;
}
示例9: JacksonInitializer
import com.fasterxml.jackson.datatype.jsr310.JSR310Module; //导入依赖的package包/类
public JacksonInitializer() {
mapper = new ObjectMapper()
.registerModule(new JSR310Module())
.registerModule(new Hibernate5Module())
.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
}
示例10: createDefaultMapper
import com.fasterxml.jackson.datatype.jsr310.JSR310Module; //导入依赖的package包/类
public static ObjectMapper createDefaultMapper() {
final ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
mapper.configure(SerializationFeature.CLOSE_CLOSEABLE, true);
mapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE);
mapper.registerModule(getCloseableIterableDeserialiserModule());
// Using the deprecated version for compatibility with older versions of jackson
mapper.registerModule(new JSR310Module());
// Use the 'setFilters' method so it is compatible with older versions of jackson
mapper.setFilters(getFilterProvider());
return mapper;
}
示例11: createMessageEnvelopeMapper
import com.fasterxml.jackson.datatype.jsr310.JSR310Module; //导入依赖的package包/类
/**
* @return creates an instance of "default" object mapper that is used to parse message envelope (without payload)
*/
public ObjectMapper createMessageEnvelopeMapper() {
return new ObjectMapper()
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
.setSerializationInclusion(JsonInclude.Include.NON_NULL)
.registerModule(new JSR310Module());
}
示例12: objectMapper
import com.fasterxml.jackson.datatype.jsr310.JSR310Module; //导入依赖的package包/类
@Bean
public ObjectMapper objectMapper() {
final ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new BatchJacksonModule());
mapper.registerModule(new JSR310Module());
return mapper;
}
示例13: JsonEventStore
import com.fasterxml.jackson.datatype.jsr310.JSR310Module; //导入依赖的package包/类
public JsonEventStore(File file) {
this.file = file;
// mapper.enable(SerializationFeature.INDENT_OUTPUT);
mapper.enable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
mapper.registerModule(new JSR310Module());
}
示例14: registerExtraModules
import com.fasterxml.jackson.datatype.jsr310.JSR310Module; //导入依赖的package包/类
public static ObjectMapper registerExtraModules(ObjectMapper objectMapper) {
objectMapper.registerModule(new GuavaModule());
objectMapper.registerModule(new Jdk8Module());
// jsr310 is basically just the jdk 8 date/time classes split into its own module
objectMapper.registerModule(new JSR310Module());
objectMapper.registerModule(new JodaModule());
objectMapper.registerModule(new ExecutorsModule());
return objectMapper;
}
示例15: getJacksonProvider
import com.fasterxml.jackson.datatype.jsr310.JSR310Module; //导入依赖的package包/类
private JacksonJsonProvider getJacksonProvider() {
JacksonJsonProvider jacksonProvider = new JacksonJsonProvider();
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JSR310Module());
mapper.setSerializationInclusion(Include.NON_EMPTY);
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
jacksonProvider.setMapper(mapper);
return jacksonProvider;
}