當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。