本文整理汇总了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);
}
}
示例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));
}
示例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;
}
示例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;
}
示例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 );
}
示例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;
}
示例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));
}
示例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);
}
}
示例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>() {
};
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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);
}
}
示例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);
}