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


Java ObjectMapper.configure方法代码示例

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


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

示例1: readInternal

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
protected <R extends Object> R readInternal(final DocumentDbPersistentEntity<?> entity, Class<R> type,
                                            final Document sourceDocument) {
    final ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    try {
        final DocumentDbPersistentProperty idProperty = entity.getIdProperty();
        final Object idValue = sourceDocument.getId();

        final JSONObject jsonObject = new JSONObject(sourceDocument.toJson());
        if (idProperty != null) {
            // Replace the key id to the actual id field name in domain
            jsonObject.remove("id");
            jsonObject.put(idProperty.getName(), idValue);
        }

        return objectMapper.readValue(jsonObject.toString(), type);
    } catch (IOException e) {
        throw  new IllegalStateException("Failed to read the source document " + sourceDocument.toJson()
                + "  to target type " + type, e);
    }
}
 
开发者ID:Microsoft,项目名称:spring-data-documentdb,代码行数:22,代码来源:MappingDocumentDbConverter.java

示例2: LogicalPlanPersistence

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
public LogicalPlanPersistence(SabotConfig conf, ScanResult scanResult) {
  mapper = new ObjectMapper();

  SimpleModule deserModule = new SimpleModule("LogicalExpressionDeserializationModule")
      .addDeserializer(LogicalExpression.class, new LogicalExpression.De(conf))
      .addDeserializer(SchemaPath.class, new SchemaPath.De());

  mapper.registerModule(new AfterburnerModule());
  mapper.registerModule(deserModule);
  mapper.enable(SerializationFeature.INDENT_OUTPUT);
  mapper.configure(Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
  mapper.configure(JsonGenerator.Feature.QUOTE_FIELD_NAMES, true);
  mapper.configure(Feature.ALLOW_COMMENTS, true);
  registerSubtypes(LogicalOperatorBase.getSubTypes(scanResult));
  registerSubtypes(StoragePluginConfigBase.getSubTypes(scanResult));
  registerSubtypes(FormatPluginConfigBase.getSubTypes(scanResult));
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:18,代码来源:LogicalPlanPersistence.java

示例3: 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

示例4: jsonDesSerialization

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
/**
 * Des-Serialize an object who was in json format
 * @param jsonObject
 * @return
 * @throws Exception 
 */
public static Program jsonDesSerialization(JsonNode jsonObject) throws Exception
{
    Program object;
    ObjectMapper mapper = new ObjectMapper();
    DateFormat myDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
    mapper.setDateFormat(myDateFormat); 
    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    object = mapper.convertValue(jsonObject,Program.class);
    return object;
}
 
开发者ID:ejesposito,项目名称:CS6310O01,代码行数:17,代码来源:Program.java

示例5: JsonHelper

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
/**
 * Instantiates a new Json helper.
 */
public JsonHelper() {
    objectMapper = new ObjectMapper();
    objectMapper.configure( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false );
    objectMapper.configure( DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true );
}
 
开发者ID:tenable,项目名称:Tenable.io-SDK-for-Java,代码行数:9,代码来源:JsonHelper.java

示例6: getObjectMapper

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
public static ObjectMapper getObjectMapper(){
    ObjectMapper mapper = new ObjectMapper();
    mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    return mapper;
}
 
开发者ID:BriData,项目名称:DBus,代码行数:7,代码来源:JsonUtil.java

示例7: getRestTemplate

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
protected RestTemplate getRestTemplate() {
	ObjectMapper mapper = new ObjectMapper();
	mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
	mapper.registerModule(new Jackson2HalModule());

	MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
	converter.setSupportedMediaTypes(Arrays.asList(MediaTypes.HAL_JSON));
	converter.setObjectMapper(mapper);

	return new RestTemplate(Collections.<HttpMessageConverter<?>>singletonList(converter));
}
 
开发者ID:ewolff,项目名称:microservice-kubernetes,代码行数:12,代码来源:CustomerClient.java

示例8: setPlatformStatusAsAppStatusList

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@JsonIgnore
public void setPlatformStatusAsAppStatusList(List<AppStatus> appStatusList) {
	ObjectMapper objectMapper = new ObjectMapper();
	// Avoids serializing objects such as OutputStreams in LocalDeployer.
	objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
	try {
		this.platformStatus = objectMapper.writeValueAsString(appStatusList);
	}
	catch (JsonProcessingException e) {
		// TODO replace with SkipperException when it moves to domain module.
		throw new IllegalArgumentException("Could not serialize list of Application Status", e);
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-skipper,代码行数:14,代码来源:Status.java

示例9: benchSetup

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@Setup(Level.Trial)
public void benchSetup(BenchmarkParams params) {
    objectMapper = new ObjectMapper();
    objectMapper.registerModule(new AfterburnerModule());
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    typeReference = new TypeReference<TestReadObject>() {
    };
}
 
开发者ID:json-iterator,项目名称:java-benchmark,代码行数:9,代码来源:DeserJackson.java

示例10: getObjectMapper

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
private ObjectMapper getObjectMapper() {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);

    return objectMapper;
}
 
开发者ID:upnext,项目名称:BeaconControl_Android_sample_app,代码行数:8,代码来源:BeaconControlManager.java

示例11: mappingJackson2HttpMessageConverter

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@Bean
public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() {
    MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter();
    jsonConverter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/hal+json"));
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    objectMapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
    objectMapper.registerModule(new Jackson2HalModule());
    jsonConverter.setObjectMapper(objectMapper);
    return jsonConverter;
}
 
开发者ID:xiaojieliu7,项目名称:MicroServiceProject,代码行数:12,代码来源:Application.java

示例12: setUp

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() {
  // Initialize object mapper for testing.
  mapper = new ObjectMapper();
  // With this configuration we save a lot of quotes and escaping when creating JSON strings.
  mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
  mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
  // Initialize validator for testing including custom mappings.
  validator = Validation.byDefaultProvider()
          .configure()
          .addMapping(AbstractRequestTest.class.getClassLoader().getResourceAsStream(VALIDATION_MAPPINGS))
          .buildValidatorFactory()
          .getValidator();
}
 
开发者ID:mnemonic-no,项目名称:act-platform,代码行数:15,代码来源:AbstractRequestTest.java

示例13: jsonDesSerialization

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
/**
 * Des-Serialize an object who was in json format
 * @param jsonObject
 * @return
 * @throws Exception 
 */
public static Allocation jsonDesSerialization(JsonNode jsonObject) throws Exception
{
    Allocation object;
    ObjectMapper mapper = new ObjectMapper();
    DateFormat myDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
    mapper.setDateFormat(myDateFormat); 
    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    object = mapper.convertValue(jsonObject,Allocation.class);
    return object;
}
 
开发者ID:ejesposito,项目名称:CS6310O01,代码行数:17,代码来源:Allocation.java

示例14: getEnvironmentV1

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
public Environment getEnvironmentV1(Application app) {

		String url = app.endpoints().env();

		try {
			LOGGER.debug("GET {}", url);
			ResponseEntity<String> response = restTemplates.get(app).getForEntity(url, String.class);

			String json = response.getBody();

			ObjectMapper mapper = new ObjectMapper();
			mapper.configure(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES, false);
			JsonNode rootNode = mapper.readTree(json);

			List<PropertyItem> properties = new ArrayList<>();

			Iterator<Entry<String, JsonNode>> iterator = rootNode.fields();

			// Get properties
			while (iterator.hasNext()) {
				Entry<String, JsonNode> current = iterator.next();

				current.getValue().fields().forEachRemaining(
						// current.getKey ==> origin of the property : system,
						// application.properties, etc
						p -> properties.add(new PropertyItem(p.getKey(), p.getValue().asText(), current.getKey())));
			}

			return new Environment(properties);
		} catch (RestClientException ex) {
			throw RestTemplateErrorHandler.handle(app, url, ex);
		} catch (IOException e) {
			throw RestTemplateErrorHandler.handle(app, e);
		}
	}
 
开发者ID:vianneyfaivre,项目名称:Persephone,代码行数:36,代码来源:EnvironmentService.java

示例15: testProcessDefaultIdentityQuery

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@Test
public void testProcessDefaultIdentityQuery()
        throws NoSuchSessionException, NoSuchTapestryDefinitionException, IllegalAccessException,
        UnsupportedOperationException, OperationException, NoSuchAggregationException, InvalidQueryInputException,
        LogicalIdAlreadyExistsException, NoSuchQueryDefinitionException, NoSuchThreadDefinitionException,
        OperationNotSupportedException, InvalidQueryParametersException, PendingQueryResultsException,
        ItemPropertyNotFound, RelationPropertyNotFound, IllegalArgumentException, ThreadDeletedByDynAdapterUnload {
    tap = new TapestryDefinition();
    tap.setThreads(defaultIdentityThreads);
    tapestryManager.setTapestryDefinition(session, tap);

    StopWatch watch = new StopWatch();
    LOG.info("testing Identity Query process");
    watch.start();
    QueryResult results = queryExec.processQuery(session, defaultIdentityThreads.get(0));

    ObjectMapper mapper = new ObjectMapper();
    mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
    try {
        System.out.println(mapper.writeValueAsString(results));
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    }

    assertTrue(results.getElements().size() == 20);

    watch.stop();
    LOG.info("tested Identity Query process --> " + watch);
}
 
开发者ID:HewlettPackard,项目名称:loom,代码行数:30,代码来源:QueryExecutorImplTest.java


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