当前位置: 首页>>代码示例>>Java>>正文


Java ObjectMapper.setPropertyNamingStrategy方法代码示例

本文整理汇总了Java中com.fasterxml.jackson.databind.ObjectMapper.setPropertyNamingStrategy方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectMapper.setPropertyNamingStrategy方法的具体用法?Java ObjectMapper.setPropertyNamingStrategy怎么用?Java ObjectMapper.setPropertyNamingStrategy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.fasterxml.jackson.databind.ObjectMapper的用法示例。


在下文中一共展示了ObjectMapper.setPropertyNamingStrategy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: SiloTemplateResolver

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的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;
}
 
开发者ID:cvent,项目名称:pangaea,代码行数:22,代码来源:SiloTemplateResolver.java

示例2: insertDataset

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
public static void insertDataset(JsonNode dataset)
  throws Exception {

  ObjectMapper om = new ObjectMapper();
  om.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
  DatasetRecord record = om.convertValue(dataset, DatasetRecord.class);

  if (record.getRefDatasetUrn() != null) {
    Map<String, Object> refDataset = getDatasetByUrn(record.getRefDatasetUrn());
    // Find ref dataset id
    if (refDataset != null) {
      record.setRefDatasetId(((Long) refDataset.get("id")).intValue());
    }
  }


  DatabaseWriter dw = new DatabaseWriter(JdbcUtil.wherehowsJdbcTemplate, "dict_dataset");
  dw.append(record);
  dw.close();
}
 
开发者ID:SirAeroWN,项目名称:premier-wherehows,代码行数:21,代码来源:DatasetDao.java

示例3: setDatasetRecord

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
public static void setDatasetRecord (JsonNode dataset) throws Exception {
  ObjectMapper om = new ObjectMapper();
  om.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
  DatasetRecord record = om.convertValue(dataset, DatasetRecord.class);

  if (record != null) {
    Map<String, Object> params = new HashMap<>();
    params.put("urn", record.getUrn());
    if (record.getUrn().indexOf(":///") == -1) {
      throw new Exception("improperly formatted urn: " + record.getUrn() + ", requires ':///'");
    }
    try {
      Map<String, Object> result = JdbcUtil.wherehowsNamedJdbcTemplate.queryForMap(GET_DATASET_BY_URN, params);
      updateDataset(dataset);
    } catch (EmptyResultDataAccessException e) {
      insertDataset(dataset);
    }
  }
}
 
开发者ID:SirAeroWN,项目名称:premier-wherehows,代码行数:20,代码来源:DatasetDao.java

示例4: updateDataset

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
public static void updateDataset(JsonNode dataset)
  throws Exception {
  ObjectMapper om = new ObjectMapper();
  om.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
  DatasetRecord record = om.convertValue(dataset, DatasetRecord.class);
  if (record.getRefDatasetUrn() != null) {
    Map<String, Object> refDataset = getDatasetByUrn(record.getRefDatasetUrn());
    // Find ref dataset id
    if (refDataset != null) {
      record.setRefDatasetId(((Long) refDataset.get("id")).intValue());
    }
  }

  DatabaseWriter dw = new DatabaseWriter(JdbcUtil.wherehowsJdbcTemplate, "dict_dataset");
  dw.update(record.toUpdateDatabaseValue(), record.getUrn());
  dw.close();
}
 
开发者ID:SirAeroWN,项目名称:premier-wherehows,代码行数:18,代码来源:DatasetDao.java

示例5: insertDataset

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
public static void insertDataset(JsonNode dataset)
  throws Exception {

  ObjectMapper om = new ObjectMapper();
  om.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
  DatasetRecord record = om.convertValue(dataset, DatasetRecord.class);
  if (record.getRefDatasetUrn() != null) {
    Map<String, Object> refDataset = getDatasetByUrn(record.getRefDatasetUrn());
    // Find ref dataset id
    if (refDataset != null) {
      record.setRefDatasetId(((Long) refDataset.get("id")).intValue());
    }
  }


  // Find layout id
  if (record.getSamplePartitionFullPath() != null) {
    PartitionPatternMatcher ppm = new PartitionPatternMatcher(PartitionLayoutDao.getPartitionLayouts());
    record.setPartitionLayoutPatternId(ppm.analyze(record.getSamplePartitionFullPath()));
  }

  DatabaseWriter dw = new DatabaseWriter(JdbcUtil.wherehowsJdbcTemplate, "dict_dataset");
  dw.append(record);
  dw.close();
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:26,代码来源:DatasetDao.java

示例6: fieldNamingStrategyDeserialize

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@Test
public void fieldNamingStrategyDeserialize() throws IOException {
	final VPackBuilder builder = new VPackBuilder();
	builder.add(ValueType.OBJECT);
	builder.add("bla", "test");
	builder.close();
	final ObjectMapper mapper = new VPackMapper();
	mapper.setPropertyNamingStrategy(new PropertyNamingStrategy() {
		private static final long serialVersionUID = 1L;

		@Override
		public String nameForSetterMethod(
			final MapperConfig<?> config,
			final AnnotatedMethod method,
			final String defaultName) {
			return "bla";
		}
	});
	final TestEntityA entity = mapper.readValue(builder.slice().getBuffer(), TestEntityA.class);
	assertThat(entity, is(notNullValue()));
	assertThat(entity.a, is("test"));
}
 
开发者ID:arangodb,项目名称:jackson-dataformat-velocypack,代码行数:23,代码来源:VPackSerializeDeserializeTest.java

示例7: updateDataset

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
public static void updateDataset(JsonNode dataset)
  throws Exception {
  ObjectMapper om = new ObjectMapper();
  om.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
  DatasetRecord record = om.convertValue(dataset, DatasetRecord.class);
  if (record.getRefDatasetUrn() != null) {
    Map<String, Object> refDataset = getDatasetByUrn(record.getRefDatasetUrn());
    // Find ref dataset id
    if (refDataset != null) {
      record.setRefDatasetId(((Long) refDataset.get("id")).intValue());
    }
  }
  // Find layout id
  if (record.getSamplePartitionFullPath() != null) {
    PartitionPatternMatcher ppm = new PartitionPatternMatcher(PartitionLayoutDao.getPartitionLayouts());
    record.setPartitionLayoutPatternId(ppm.analyze(record.getSamplePartitionFullPath()));
  }

  DatabaseWriter dw = new DatabaseWriter(JdbcUtil.wherehowsJdbcTemplate, "dict_dataset");
  dw.update(record.toUpdateDatabaseValue(), record.getUrn());
  dw.close();
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:23,代码来源:DatasetDao.java

示例8: fieldNamingStrategySerialize

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@Test
public void fieldNamingStrategySerialize() throws IOException {
	final ObjectMapper mapper = new VPackMapper();
	mapper.setPropertyNamingStrategy(new PropertyNamingStrategy() {
		private static final long serialVersionUID = 1L;

		@Override
		public String nameForGetterMethod(
			final MapperConfig<?> config,
			final AnnotatedMethod method,
			final String defaultName) {
			return "bla";
		}
	});
	final VPackSlice vpack = new VPackSlice(mapper.writeValueAsBytes(new TestEntityA()));
	assertThat(vpack, is(notNullValue()));
	assertThat(vpack.isObject(), is(true));
	final VPackSlice bla = vpack.get("bla");
	assertThat(bla.isString(), is(true));
	assertThat(bla.getAsString(), is("a"));
}
 
开发者ID:arangodb,项目名称:jackson-dataformat-velocypack,代码行数:22,代码来源:VPackSerializeDeserializeTest.java

示例9: provideObjectMapper

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
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(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;
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:14,代码来源:RetrofitModule.java

示例10: createDefaultObjectMapper

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
private static ObjectMapper createDefaultObjectMapper() {
    final ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
    objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    objectMapper.registerModules(new Jdk8Module(), new ParameterNamesModule(), new JavaTimeModule());
    objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
    return objectMapper;
}
 
开发者ID:zalando-nakadi,项目名称:nakadi-producer-spring-boot-starter,代码行数:9,代码来源:MockNakadiPublishingClient.java

示例11: provideObjectMapper

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
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;
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:14,代码来源:RetrofitModule.java

示例12: writeToPath

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
/**
 * Writes the {@link ItemsetLibrary} to the given path.
 *
 * @param libraryPath The {@link Path} to which the {@link ItemsetLibrary} should be written.
 * @throws IOException If the writing of the {@link ItemsetLibrary} fails.
 */
public void writeToPath(Path libraryPath) throws IOException {
    try (GZIPOutputStream zip = new GZIPOutputStream(new FileOutputStream(libraryPath.toFile()));
         BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(zip, "UTF-8"))) {
        ObjectMapper mapper = new ObjectMapper();
        mapper.enable(SerializationFeature.INDENT_OUTPUT);
        mapper.setPropertyNamingStrategy(PropertyNamingStrategy.KEBAB_CASE);
        mapper.writeValue(writer, this);
    }
}
 
开发者ID:enauz,项目名称:mmm,代码行数:16,代码来源:ItemsetLibrary.java

示例13: toJson

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
/**
 * Converts this {@link ItemsetLibrary} into a Json representation.
 *
 * @return The Json representation.
 * @throws JsonProcessingException If mapping to JSON fails.
 */
public String toJson() throws JsonProcessingException {
    ObjectMapper mapper = new ObjectMapper();
    mapper.enable(SerializationFeature.INDENT_OUTPUT);
    mapper.setPropertyNamingStrategy(PropertyNamingStrategy.KEBAB_CASE);
    return mapper.writeValueAsString(this);
}
 
开发者ID:enauz,项目名称:mmm,代码行数:13,代码来源:ItemsetLibrary.java

示例14: jsonTransformService

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@Bean
public JsonTransformService jsonTransformService() {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.KEBAB_CASE);

    ResourceConverter resourceConverter = new ResourceConverter(objectMapper,
            Instance.class, Notification.class, SecurityGroup.class, User.class);

    return new JsonTransformServiceImpl(resourceConverter);
}
 
开发者ID:peavers,项目名称:swordfish-service,代码行数:11,代码来源:JsonTransformConfig.java

示例15: resourceConverter

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@Bean
public ResourceConverter resourceConverter() {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.KEBAB_CASE);

    return new ResourceConverter(objectMapper, Instance.class, Notification.class, SecurityGroup.class, User.class);
}
 
开发者ID:peavers,项目名称:swordfish-service,代码行数:8,代码来源:JsonTransformConfig.java


注:本文中的com.fasterxml.jackson.databind.ObjectMapper.setPropertyNamingStrategy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。