Java 类com.fasterxml.jackson.databind.SerializationFeature 实例源码

项目:iiif-apis    文件:IiifObjectMapper.java   
public IiifObjectMapper() {
  this.checkJacksonVersion();

  // Don't include null properties
  this.setSerializationInclusion(Include.NON_NULL);

  // Both are needed to add `@context` to the top-level object
  this.disable(SerializationFeature.FAIL_ON_UNWRAPPED_TYPE_IDENTIFIERS);
  this.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);

  // Some array fields are unwrapped during serialization if they have only one value
  this.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);

  // Register the problem handler
  this.addHandler(new ProblemHandler());

  // Disable writing dates as timestamps
  this.registerModule(new JavaTimeModule());
  this.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);

  // Enable automatic detection of parameter names in @JsonCreators
  this.registerModule(new ParameterNamesModule());

  // Register the module
  this.registerModule(new IiifModule());
}
项目:JSON-framework-comparison    文件:RuntimeSampler.java   
public static ObjectMapper objectMapper() {
    return new ObjectMapper()
            // Property visibility
            .setDefaultPropertyInclusion(JsonInclude.Include.ALWAYS)
            .setDefaultVisibility(JsonAutoDetect.Value.construct(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.PROTECTED_AND_PUBLIC))
            .configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true)
            .setSerializationInclusion(JsonInclude.Include.NON_NULL)
            .configure(SerializationFeature.WRITE_NULL_MAP_VALUES, true)

            // Property naming and order
            .setPropertyNamingStrategy(PropertyNamingStrategy.LOWER_CAMEL_CASE)

            // Customised de/serializers

            // Formats, locals, encoding, binary data
            .setDateFormat(new SimpleDateFormat("MM/dd/yyyy"))
            .setDefaultPrettyPrinter(new DefaultPrettyPrinter())
            .setLocale(Locale.CANADA);
}
项目:cas-5.1.0    文件:DefaultAuthenticationTests.java   
@Before
public void setUp() throws Exception {
    mapper = Jackson2ObjectMapperBuilder.json()
            .featuresToDisable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE)
            .featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
            .build();
    mapper.findAndRegisterModules();
}
项目:alfresco-remote-api    文件:JacksonHelper.java   
@Override
public void afterPropertiesSet() throws Exception
{
    //Configure the objectMapper ready for use
    objectMapper = new ObjectMapper();
    objectMapper.registerModule(module);
    objectMapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);  //or NON_EMPTY?
    // this is deprecated in jackson 2.9 and there is no straight replacement
    // https://github.com/FasterXML/jackson-databind/issues/1547
    objectMapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);
    objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
    DateFormat DATE_FORMAT_ISO8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
    DATE_FORMAT_ISO8601.setTimeZone(TimeZone.getTimeZone("UTC"));
    objectMapper.setDateFormat(DATE_FORMAT_ISO8601);
    objectMapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
}
项目:continuous-performance-testing    文件:EndpointApplication.java   
@Override
public void initialize(final Bootstrap<EndpointConfiguration> bootstrap) {
  bootstrap.getObjectMapper().configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);

  bootstrap.addBundle(new SwaggerBundle<EndpointConfiguration>() {
    @Override
    protected SwaggerBundleConfiguration getSwaggerBundleConfiguration(
        EndpointConfiguration configuration) {
      return configuration.swagger;
    }
  });
}
项目:Equella    文件:RestEasyServlet.java   
@Override
public void extendMapper(ObjectMapper mapper)
{
    SimpleModule restModule = new SimpleModule("RestModule", new Version(1, 0, 0, null));
    // TODO this probably should be somewhere else, but it can't be in
    // com.tle.core.jackson
    // as that would make it dependent on equella i18n
    restModule.addSerializer(new I18NSerializer());
    mapper.registerModule(restModule);
    mapper.registerModule(new JavaTypesModule());

    mapper.registerModule(new RestStringsModule());
    mapper.setSerializationInclusion(Include.NON_NULL);

    // dev mode!
    if( DebugSettings.isDebuggingMode() )
    {
        mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
    }
    mapper.setDateFormat(new ISO8061DateFormatWithTZ());

}
项目:delivery-sdk-java    文件:DeliveryClientTest.java   
@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]);
}
项目:NGB-master    文件:JsonMapper.java   
private JsonMapper() {
    // calls the default constructor
    super();

    // configures ISO8601 formatter for date without time zone
    // the used format is 'yyyy-MM-dd'
    setDateFormat(new SimpleDateFormat(FMT_ISO_LOCAL_DATE));

    // enforces to skip null and empty values in the serialized JSON output
    setSerializationInclusion(JsonInclude.Include.NON_EMPTY);

    // enforces to skip null references in the serialized output of map
    configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);

    // enables serialization failures, when mapper encounters unknown properties names
    configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

    // configures the format to prevent writing of the serialized output for dates
    // instances as timestamps; any date should be written in ISO format
    configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
}
项目:illuminati    文件:StringObjectUtils.java   
public static String objectToString (final Object object) {
    if (object == null) {
        return null;
    }

    try {
        final StringWriter stringWriter = new StringWriter();

        final ObjectMapper objectMapper = new ObjectMapper();
        objectMapper.configure(SerializationFeature.INDENT_OUTPUT, true);
        objectMapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
        objectMapper.writeValue(stringWriter, object);

        return stringWriter.toString().replaceAll(System.getProperty("line.separator"), "");
    } catch (IOException ex) {
        STRINGUTIL_LOGGER.info("Sorry. had a error on during Object to String. ("+ex.toString()+")");
        return null;
    }
}
项目:soundwave    文件:EsPropertyNamingStrategyTest.java   
@Test
public void deserializeWithStrategy() throws Exception {
  ObjectMapper
      mapper =
      new ObjectMapper().configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
          .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
          .setPropertyNamingStrategy(new EsPropertyNamingStrategy(
              EsDailySnapshotInstance.class, EsInstanceStore.class))
          .configure(MapperFeature.ALLOW_EXPLICIT_PROPERTY_RENAMING, true);

  EsDailySnapshotInstance inst = mapper.readValue(doc, EsDailySnapshotInstance.class);
  Assert.assertEquals("coreapp-webapp-prod-0a018ef5", inst.getName());
  Assert.assertEquals("fixed", inst.getLifecycle());
  Assert.assertTrue(inst.getLaunchTime() != null);

}
项目:NGB-master    文件:JsonMapper.java   
public JsonMapper() {
    // calls the default constructor
    super();

    // configures ISO8601 formatter for date without time zone
    // the used format is 'yyyy-MM-dd'
    super.setDateFormat(new SimpleDateFormat(FMT_ISO_LOCAL_DATE));

    // enforces to skip null and empty values in the serialized JSON output
    super.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);

    // enforces to skip null references in the serialized output of Map
    super.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);

    // enables serialization failures, when mapper encounters unknown properties names
    super.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true);

    // configures the format to prevent writing of the serialized output for java.util.Date
    // instances as timestamps. any date should be written in ISO format
    super.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
}
项目:OperatieBRP    文件:BrpJsonObjectMapper.java   
private void configureerMapper() {
    // Configuratie
    this.disable(MapperFeature.AUTO_DETECT_CREATORS);
    this.disable(MapperFeature.AUTO_DETECT_FIELDS);
    this.disable(MapperFeature.AUTO_DETECT_GETTERS);
    this.disable(MapperFeature.AUTO_DETECT_IS_GETTERS);
    this.disable(MapperFeature.AUTO_DETECT_SETTERS);

    // Default velden niet als JSON exposen (expliciet annoteren!)
    setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.NONE);
    this.enable(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY);
    this.enable(MapperFeature.CAN_OVERRIDE_ACCESS_MODIFIERS);

    // serialization
    this.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
    setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
    this.enable(SerializationFeature.WRITE_ENUMS_USING_INDEX);

    // deserialization
    this.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
}
项目:syndesis    文件:YamlHelpers.java   
public static ObjectMapper createObjectMapper() {
    final YAMLFactory yamlFactory = new YAMLFactory()
        .configure(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID, false)
        .configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true)
        .configure(YAMLGenerator.Feature.ALWAYS_QUOTE_NUMBERS_AS_STRINGS, true)
        .configure(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID, false);

    ObjectMapper mapper = new ObjectMapper(yamlFactory)
        .registerModule(new Jdk8Module())
        .setSerializationInclusion(JsonInclude.Include.NON_EMPTY)
        .enable(SerializationFeature.INDENT_OUTPUT)
        .disable(SerializationFeature.WRITE_NULL_MAP_VALUES);

    for (Step step : ServiceLoader.load(Step.class, YamlHelpers.class.getClassLoader())) {
        mapper.registerSubtypes(new NamedType(step.getClass(), step.getKind()));
    }

    return mapper;
}
项目:spring-cloud-starter-bootstrap    文件:DefaultJacksonConfiguration.java   
@Bean
public Jackson2ObjectMapperBuilderCustomizer jackson2ObjectMapperBuilder() {

    return builder -> {
        TimeZone tz = TimeZone.getTimeZone("UTC");
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'");
        df.setTimeZone(tz);

        builder
                .failOnEmptyBeans(false)
                .failOnUnknownProperties(false)
                .featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
                .dateFormat(df);

    };
}
项目:syndesis-integration-runtime    文件:YamlHelpers.java   
public static ObjectMapper createObjectMapper() {
    final YAMLFactory yamlFactory = new YAMLFactory()
        .configure(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID, false)
        .configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true)
        .configure(YAMLGenerator.Feature.ALWAYS_QUOTE_NUMBERS_AS_STRINGS, true)
        .configure(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID, false);

    ObjectMapper mapper = new ObjectMapper(yamlFactory)
        .setSerializationInclusion(JsonInclude.Include.NON_EMPTY)
        .enable(SerializationFeature.INDENT_OUTPUT)
        .disable(SerializationFeature.WRITE_NULL_MAP_VALUES);

    for (Step step : ServiceLoader.load(Step.class, YamlHelpers.class.getClassLoader())) {
        mapper.registerSubtypes(new NamedType(step.getClass(), step.getKind()));
    }

    return mapper;
}
项目:crnk-framework    文件:TSGenerator.java   
private void writeTypescriptConfig() throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    mapper.enable(SerializationFeature.INDENT_OUTPUT);
    ObjectNode root = mapper.createObjectNode();
    ObjectNode compilerOptions = root.putObject("compilerOptions");
    compilerOptions.put("baseUrl", "");
    compilerOptions.put("declaration", true);
    compilerOptions.put("emitDecoratorMetadata", true);
    compilerOptions.put("experimentalDecorators", true);
    compilerOptions.put("module", "es6");
    compilerOptions.put("moduleResolution", "node");
    compilerOptions.put("sourceMap", true);
    compilerOptions.put("target", "es5");
    ArrayNode typeArrays = compilerOptions.putArray("typeRoots");
    typeArrays.add("node_modules/@types");
    ArrayNode libs = compilerOptions.putArray("lib");
    libs.add("es6");
    libs.add("dom");

    File outputSourceDir = new File(outputDir, config.getSourceDirectoryName());
    File file = new File(outputSourceDir, "tsconfig.json");
    file.getParentFile().mkdirs();
    mapper.writer().writeValue(file, root);
}
项目:java-driver    文件:eclipseParser.java   
/**
 * Creates a new EclipseParser
 *
 * @param sourceFile String of source file to read
 * @param outJ       JSON parsed out
 * @throws IOException when file can't be opened or errors in reading/writing
 */
public EclipseParser(String sourceFile, PrintStream outJ, boolean prettyprint) throws IOException {

    File file = new File(sourceFile);
    final BufferedReader reader = new BufferedReader(new FileReader(file));
    char[] source = IOUtils.toCharArray(reader);
    reader.close();
    this.parser = ASTParser.newParser(AST.JLS8);
    parser.setSource(source);
    parser.setKind(ASTParser.K_COMPILATION_UNIT);

    final JsonFactory jsonF = new JsonFactory();
    jG = jsonF.createGenerator(outJ);
    if (prettyprint) {
        jG.setPrettyPrinter(new DefaultPrettyPrinter());
        mapper.enable(SerializationFeature.INDENT_OUTPUT);
    }
    mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
    mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
    mapper.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
    SimpleModule module = new SimpleModule();
    module.addSerializer(ASTNode.class, new NodeSerializer());
    mapper.registerModule(module);
}
项目:xm-ms-entity    文件:ElasticPathStrategy.java   
@Override
public <T> T map(String json, Class<T> clazz) {
    if (null == json) {
        throw new IllegalArgumentException("Can not map empty json");
    }
    ObjectMapper mapper = new ObjectMapper();
    mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
    mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    JsonUnmarshaller jsonUnmarshaller = new FixedDefaultJsonUnmarshaller(mapper);
    try {
        return jsonUnmarshaller.unmarshal(clazz, json);
    } catch (IOException e) {
        log.warn("Error during mapping", e);
        return null;
    }
}
项目:server    文件:ObjectMapperProvider.java   
public static ObjectMapper createDefaultMapper() {

        final ObjectMapper mapper = new ObjectMapper();
        mapper.setSerializationInclusion(Include.NON_NULL);
        mapper.configure(SerializationFeature.INDENT_OUTPUT, false);
        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        mapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);

        SimpleModule module = new SimpleModule();
        module.addSerializer(Transaction.class, new TransactionSerializer());
        module.addDeserializer(Transaction.class, new TransactionDeserializer());
        module.addSerializer(Difficulty.class, new DifficultySerializer());
        module.addDeserializer(Difficulty.class, new DifficultyDeserializer());
        module.addSerializer(Block.class, new BlockSerializer());
        module.addDeserializer(Block.class, new BlockDeserializer());
        mapper.registerModule(module);

        return mapper;

    }
项目:ares    文件:FloodAttackJsonMapper.java   
/**
 * Initializes the JSON constructor.
 */
public FloodAttackJsonMapper() {
  super();
  SimpleModule module = new SimpleModule();
  module.addSerializer(HttpFloodAttack.class, HttpFloodAttackSerializer.getInstance());
  module.addDeserializer(HttpFloodAttack.class, HttpFloodAttackDeserializer.getInstance());
  super.registerModule(module);
  super.enable(SerializationFeature.INDENT_OUTPUT);
}
项目:syndesis-verifier    文件:JacksonContextResolver.java   
public JacksonContextResolver() throws Exception {
    this.objectMapper = new ObjectMapper()
        .registerModule(new Jdk8Module())
        .setSerializationInclusion(JsonInclude.Include.NON_ABSENT)
        .configure(DeserializationFeature.READ_ENUMS_USING_TO_STRING, true)
        .configure(SerializationFeature.WRITE_ENUMS_USING_TO_STRING, true);
}
项目:AppCoins-ethereumj    文件:RetrofitModule.java   
public ObjectMapper provideObjectMapper() {
  ObjectMapper objectMapper = new ObjectMapper();
  objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
  objectMapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);
  objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
  objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
  objectMapper.configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL, true);
  objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);

  objectMapper.setDateFormat(provideDateFormat());

  return objectMapper;
}
项目:incubator-servicecomb-java-chassis    文件:RestObjectMapper.java   
private RestObjectMapper() {
  // swagger中要求date使用ISO8601格式传递,这里与之做了功能绑定,这在cse中是没有问题的
  setDateFormat(new ISO8601DateFormat());
  getFactory().disable(Feature.AUTO_CLOSE_SOURCE);
  disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
  disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
}
项目:koryphe    文件:JsonSerialiser.java   
private static ObjectMapper createObjectMapper() {
    final ObjectMapper mapper = new ObjectMapper();
    mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    mapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT);
    mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
    return mapper;
}
项目:loom    文件:FileSystemAdapterTest.java   
private String toJson(final Object object) throws JsonProcessingException {
    ObjectMapper mapper = new ObjectMapper();
    mapper.enable(SerializationFeature.INDENT_OUTPUT);
    String jsonRep = "";
    jsonRep = mapper.writeValueAsString(object);
    return jsonRep;
}
项目:cas-server-4.2.1    文件:AbstractJacksonBackedJsonSerializer.java   
/**
 * Initialize object mapper.
 *
 * @return the object mapper
 */
protected ObjectMapper initializeObjectMapper() {
    final ObjectMapper mapper = new ObjectMapper();
    mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
    mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
    mapper.setVisibility(PropertyAccessor.SETTER, JsonAutoDetect.Visibility.PROTECTED_AND_PUBLIC);
    mapper.setVisibility(PropertyAccessor.GETTER, JsonAutoDetect.Visibility.PROTECTED_AND_PUBLIC);
    mapper.setVisibility(PropertyAccessor.IS_GETTER, JsonAutoDetect.Visibility.PROTECTED_AND_PUBLIC);
    mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
    return mapper;
}
项目:cmc-claim-store    文件:JacksonConfiguration.java   
public ObjectMapper objectMapper() {
    return new ObjectMapper()
        .registerModule(new Jdk8Module())
        .registerModule(new ParameterNamesModule(JsonCreator.Mode.PROPERTIES))
        .registerModule(new JavaTimeModule()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
        .disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
}
项目:azure-libraries-for-java    文件:InterceptorManager.java   
private void readDataFromFile() throws IOException {
    File recordFile = getRecordFile(testName);
    ObjectMapper mapper = new ObjectMapper();
    mapper.enable(SerializationFeature.INDENT_OUTPUT);
    recordedData = mapper.readValue(recordFile, RecordedData.class);
    System.out.println("Total records " + recordedData.getNetworkCallRecords().size());
}
项目:liferay-service-builder-dsl    文件:BaseXMLSerializer.java   
/**
 * Serializes the Service Builder element (entity, finder, order, etc) into
 * a String representing the XML output.
 *
 * @return the serialized service builder element
 * @throws JsonProcessingException if an exception occurs
 */
@Override
public String serialize() throws JsonProcessingException {
    ObjectMapper xmlMapper = new XmlMapper();

    xmlMapper.enable(SerializationFeature.INDENT_OUTPUT);
    xmlMapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);

    return xmlMapper.writeValueAsString(_serviceBuilderElement);
}
项目:friendly-id    文件:MvcTest.java   
protected Jackson2ObjectMapperBuilder jacksonBuilder() {
    Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
    builder.modules(new ParameterNamesModule(JsonCreator.Mode.PROPERTIES), new JavaTimeModule(), new FriendlyIdModule());
    builder.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    builder.simpleDateFormat("yyyy-MM-dd");
    builder.indentOutput(true);
    return builder;
}
项目:springboot-shiro-cas-mybatis    文件:AbstractJacksonBackedJsonSerializer.java   
/**
 * Initialize object mapper.
 *
 * @return the object mapper
 */
protected ObjectMapper initializeObjectMapper() {
    final ObjectMapper mapper = new ObjectMapper();
    mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
    mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
    mapper.setVisibility(PropertyAccessor.SETTER, JsonAutoDetect.Visibility.PROTECTED_AND_PUBLIC);
    mapper.setVisibility(PropertyAccessor.GETTER, JsonAutoDetect.Visibility.PROTECTED_AND_PUBLIC);
    mapper.setVisibility(PropertyAccessor.IS_GETTER, JsonAutoDetect.Visibility.PROTECTED_AND_PUBLIC);
    mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
    return mapper;
}
项目:springboot-shiro-cas-mybatis    文件:AbstractJacksonBackedJsonSerializer.java   
/**
 * Initialize object mapper.
 *
 * @return the object mapper
 */
protected ObjectMapper initializeObjectMapper() {
    final ObjectMapper mapper = new ObjectMapper();
    mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
    mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
    mapper.setVisibility(PropertyAccessor.SETTER, JsonAutoDetect.Visibility.PROTECTED_AND_PUBLIC);
    mapper.setVisibility(PropertyAccessor.GETTER, JsonAutoDetect.Visibility.PROTECTED_AND_PUBLIC);
    mapper.setVisibility(PropertyAccessor.IS_GETTER, JsonAutoDetect.Visibility.PROTECTED_AND_PUBLIC);
    mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
    return mapper;
}
项目:QDrill    文件:AbstractDynamicBean.java   
private static synchronized ObjectMapper getMapper(){
  if(MAPPER == null){
    ObjectMapper mapper = new ObjectMapper();
    mapper.enable(SerializationFeature.INDENT_OUTPUT);
    mapper.configure(Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
    mapper.configure(Feature.ALLOW_COMMENTS, true);
    MAPPER = mapper;
  }
  return MAPPER;
}
项目:cas-5.1.0    文件:AbstractJacksonBackedStringSerializer.java   
/**
 * Configure mapper.
 *
 * @param mapper the mapper
 */
protected void configureObjectMapper(final ObjectMapper mapper) {
    mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false)
            .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

    mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
    mapper.setVisibility(PropertyAccessor.SETTER, JsonAutoDetect.Visibility.PROTECTED_AND_PUBLIC);
    mapper.setVisibility(PropertyAccessor.GETTER, JsonAutoDetect.Visibility.PROTECTED_AND_PUBLIC);
    mapper.setVisibility(PropertyAccessor.IS_GETTER, JsonAutoDetect.Visibility.PROTECTED_AND_PUBLIC);

    if (isDefaultTypingEnabled()) {
        mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
    }
    mapper.findAndRegisterModules();
}
项目:cas-5.1.0    文件:ServiceTicketImplTests.java   
@Before
public void setUp() throws Exception {
    // needed in order to serialize ZonedDateTime class
    mapper = Jackson2ObjectMapperBuilder.json()
            .featuresToDisable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE)
            .featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
            .build();
    mapper.findAndRegisterModules();
}
项目:cas-5.1.0    文件:TicketGrantingTicketImplTests.java   
@Before
public void setUp() throws Exception {
    // needed in order to serialize ZonedDateTime class
    mapper = Jackson2ObjectMapperBuilder.json()
            .featuresToDisable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE)
            .featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
            .build();
    mapper.findAndRegisterModules();
}
项目:stdds-monitor    文件:CSVWriter.java   
public CSVWriter(Class<T> class1, Class<?> mixin) {
    mapper = new CsvMapper();
    mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    mapper.setDateFormat(new ISO8601WithMillisFormat());
    if (mixin != null) {
        mapper.addMixIn(class1, mixin);
    }
    schema = mapper.schemaFor(class1).withHeader();
}
项目:LazyREST    文件:CustomObjectMapper.java   
public void init() {
    // 排除值为空属性
    setSerializationInclusion(JsonInclude.Include.NON_NULL);
    // 进行缩进输出
    configure(SerializationFeature.INDENT_OUTPUT, true);
    // 将驼峰转为下划线
    if (camelCaseToLowerCaseWithUnderscores) {
        setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
    }
    // 进行日期格式化
    if (!StringUtils.isEmpty(dateFormatPattern)) {
        DateFormat dateFormat = new SimpleDateFormat(dateFormatPattern);
        setDateFormat(dateFormat);
    }
}
项目:spring-rest-commons-options    文件:WebMvcConfiguration.java   
YamlJackson2HttpMessageConverter() {
    super(new YAMLMapper().enable(Feature.MINIMIZE_QUOTES), MediaType.parseMediaType("application/x-yaml"));
    this.getObjectMapper().configure(JsonGenerator.Feature.QUOTE_FIELD_NAMES, false);
    this.getObjectMapper().configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
    this.getObjectMapper().enable(SerializationFeature.INDENT_OUTPUT);
    this.getObjectMapper().setSerializationInclusion(Include.NON_NULL);
}