use of com.fasterxml.jackson.dataformat.xml.XmlMapper in project spring-framework by spring-projects.
the class Jackson2ObjectMapperFactoryBeanTests method setObjectMapper.
@Test
public void setObjectMapper() {
this.factory.setObjectMapper(new XmlMapper());
this.factory.afterPropertiesSet();
assertNotNull(this.factory.getObject());
assertTrue(this.factory.isSingleton());
assertEquals(XmlMapper.class, this.factory.getObjectType());
}
use of com.fasterxml.jackson.dataformat.xml.XmlMapper in project torodb by torodb.
the class ConfigUtils method getParam.
public static <T> JsonNode getParam(T config, String pathAndProp) throws Exception {
XmlMapper xmlMapper = xmlMapper();
JsonNode configNode = xmlMapper.valueToTree(config);
if (JsonPointer.compile(pathAndProp).equals(JsonPointer.compile("/"))) {
return configNode;
}
JsonPointer pathPointer = JsonPointer.compile(pathAndProp);
JsonNode pathNode = configNode.at(pathPointer);
if (pathNode.isMissingNode() || pathNode.isNull()) {
return null;
}
return pathNode;
}
use of com.fasterxml.jackson.dataformat.xml.XmlMapper in project torodb by torodb.
the class ConfigUtils method readConfigFromXml.
public static <T> T readConfigFromXml(Class<T> configClass, String xmlString) throws JsonProcessingException, IOException {
ObjectMapper objectMapper = mapper();
XmlMapper xmlMapper = xmlMapper();
JsonNode configNode = xmlMapper.readTree(xmlString);
T config = objectMapper.treeToValue(configNode, configClass);
validateBean(config);
return config;
}
Aggregations