com.fasterxml.jackson.datatype.jsr310.JSR310Module.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(187)

本文整理了Java中com.fasterxml.jackson.datatype.jsr310.JSR310Module.<init>()方法的一些代码示例,展示了JSR310Module.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSR310Module.<init>()方法的具体详情如下:
包路径:com.fasterxml.jackson.datatype.jsr310.JSR310Module
类名称:JSR310Module
方法名:<init>

JSR310Module.<init>介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JSR310Module;
import javax.ws.rs.ext.ContextResolver;
import javax.ws.rs.ext.Provider;

@Provider
public class ObjectMapperContextResolver implements ContextResolver<ObjectMapper> {  
  private final ObjectMapper MAPPER;

  public ObjectMapperContextResolver() {
    MAPPER = new ObjectMapper();
    MAPPER.registerModule(new JSR310Module());
    MAPPER.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
  }

  @Override
  public ObjectMapper getContext(Class<?> type) {
    return MAPPER;
  }  
}

代码示例来源:origin: gchq/Gaffer

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(CloseableIterableDeserializer.getModule());
  // Allow unknown properties. This will help to avoid conflicts between Gaffer versions.
  mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, STRICT_JSON_DEFAULT);
  // 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());
  // Allow simple class names or full class names to be used in JSON.
  // We must set this to true to ensure serialisation into json uses the
  // full class name. Otherwise, json deserialisation may fail on worker nodes in Accumulo/HBase.
  SimpleClassNameCache.setUseFullNameForSerialisation(true);
  SimpleClassNameIdResolver.configureObjectMapper(mapper);
  return mapper;
}

代码示例来源:origin: stackoverflow.com

@Configuration
public class JacksonConfiguration {

  @Bean
  public JSR310Module jsr310Module() {
    return new JSR310Module();
  }
}

代码示例来源:origin: com.bq.corbel/event-bus

@Bean
public ObjectMapper getObjectMapper() {
  ObjectMapper mapper = new ObjectMapper();
  mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
  mapper.registerModule(new JSR310Module());
  return mapper;
}

代码示例来源:origin: com.bq.oss.corbel/event-bus

@Bean
public ObjectMapper getObjectMapper() {
  ObjectMapper mapper = new ObjectMapper();
  mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
  mapper.registerModule(new JSR310Module());
  return mapper;
}

代码示例来源:origin: pl.touk.widerest/widerest-api

@PostConstruct
public void initJodaTimeJacksonModule() {
  objectMappers.forEach(objectMapper -> {
    objectMapper.registerModule(new JSR310Module());
    objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    objectMapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE);
  });
}

代码示例来源:origin: com.netflix.spinnaker.tide/tide-core

public void configureObjectMapper(ObjectMapper objectMapper) {
 objectMapper.registerModule(DefaultScalaModule$.MODULE$)
  .registerModule(new JSR310Module())
  .disable(WRITE_DATES_AS_TIMESTAMPS)
  .enable(ACCEPT_SINGLE_VALUE_AS_ARRAY)
  .enable(ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
}

代码示例来源:origin: com.opentable.components/otj-logging-core

public JsonLogEncoder() {
  // TODO: This sucks - - won't get the mapper customizations.  Find a way to inject this.
  // Master configuration is in otj-jackson
  this.mapper = new ObjectMapper()
      .registerModule(new JSR310Module())
      .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
      .disable(SerializationFeature.WRITE_NULL_MAP_VALUES)
      .setSerializationInclusion(Include.NON_NULL)
      .configure(Feature.AUTO_CLOSE_TARGET, false);
}

代码示例来源:origin: stackoverflow.com

public class Java8DateFormat {
  public static void main(String[] args) throws IOException {
    final ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(new JSR310Module());
    // mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"));

    final String date = mapper.writeValueAsString(new Date());
    System.out.println(date);
    System.out.println(mapper.readValue(date, ZonedDateTime.class));
  }
}

代码示例来源:origin: thoersch/spring-boot-rest-api-seed

@Bean
public ObjectMapper getObjectMapper() {
  return new ObjectMapper()
      .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
      .configure(SerializationFeature.INDENT_OUTPUT, true)
      .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
      .registerModule(new JSR310Module());
}

代码示例来源:origin: stackoverflow.com

ObjectMapper mapper = new ObjectMapper();
 mapper.registerModule(new Jdk8Module());
 mapper.registerModule(new JSR310Module());
 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
 Json.setObjectMapper(mapper);

代码示例来源:origin: stackoverflow.com

@Provider
@Produces(MediaType.APPLICATION_JSON)
public class JacksonContextResolver implements ContextResolver<ObjectMapper> {
 private static final ObjectMapper om = init();

 @Override public ObjectMapper getContext(Class<?> objectType) {
  return om;
 }

 private static ObjectMapper init() {
  ObjectMapper om = new ObjectMapper();
  om.registerModule(new JSR310Module());
  return om;
 }
}

代码示例来源:origin: restx/restx

@Provides
public com.fasterxml.jackson.databind.Module jsr310Module() {
  return new JSR310Module();
}

代码示例来源:origin: io.restx/restx-core-java8

@Provides
public com.fasterxml.jackson.databind.Module jsr310Module() {
  return new JSR310Module();
}

代码示例来源:origin: com.bazaarvoice.emodb/emodb-common-json

public static ObjectMapper configure(ObjectMapper mapper) {
    return mapper
        .registerModule(new Jdk8Module())
        .registerModule(new JSR310Module())
        .configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false)
        // The following module present to maintain compatibility in the API clients caused by importing DropWizard.
        // Eventually all API clients should have minimal dependencies. At that time Guava will be removed and the
        // JSON support for Guava objects will also be removed.
        .registerModule(new GuavaModule());
  }
}

代码示例来源:origin: bazaarvoice/emodb

public static ObjectMapper configure(ObjectMapper mapper) {
    return mapper
        .registerModule(new Jdk8Module())
        .registerModule(new JSR310Module())
        .configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false)
        // The following module present to maintain compatibility in the API clients caused by importing DropWizard.
        // Eventually all API clients should have minimal dependencies. At that time Guava will be removed and the
        // JSON support for Guava objects will also be removed.
        .registerModule(new GuavaModule());
  }
}

代码示例来源:origin: HubSpot/slack-client

private static ObjectMapper create() {
 ObjectMapper mapper = new ObjectMapper();
 mapper.registerModule(new GuavaModule());
 mapper.registerModule(new JodaModule());
 mapper.registerModule(new Jdk8Module());
 mapper.registerModule(new JSR310Module());
 mapper.configure(JsonParser.Feature.ALLOW_COMMENTS, false);
 mapper.configure(JsonParser.Feature.AUTO_CLOSE_SOURCE, true);
 mapper.configure(JsonGenerator.Feature.AUTO_CLOSE_TARGET, true);
 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
 return mapper;
}

代码示例来源:origin: thoersch/spring-boot-rest-api-seed

public ApplicationConfigurationParser() {
  yamlMapper = new ObjectMapper(new YAMLFactory())
      .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
      .registerModule(new JSR310Module());
  validator = Validation.byProvider(HibernateValidator.class)
      .configure()
      .buildValidatorFactory()
      .getValidator();
}

代码示例来源:origin: com.teradata.airlift/json

public ObjectMapperProvider()
{
  modules.add(new Jdk8Module());
  modules.add(new JSR310Module());
  modules.add(new GuavaModule());
  modules.add(new JodaModule());
}

代码示例来源:origin: io.sphere.sdk.jvm/common

public static ObjectMapper newObjectMapper() {
  return new ObjectMapper()
      .registerModule(new JavaOptionalModule())
      .registerModule(new ParameterNamesModule())
      .registerModule(new JSR310Module())//Java 8 DateTime
      .registerModule(new DateTimeSerializationModule())
      .registerModule(new JavaMoneyModule())
      .registerModule(new SphereEnumModule())
      .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}

相关文章

微信公众号

最新文章

更多

JSR310Module类方法