use of com.fasterxml.jackson.dataformat.xml.XmlMapper in project tikxml by Tickaroo.
the class JacksonMediumXmlBenchmark method parse.
public void parse(String xml) throws Exception {
XmlMapper mapper = new XmlMapper();
Feed feed = mapper.readValue(xml, Feed.class);
System.out.println(getClass().getSimpleName() + " " + feed);
}
use of com.fasterxml.jackson.dataformat.xml.XmlMapper in project streamline by hortonworks.
the class ConfigFileReader method readConfigFromHadoopXmlType.
private Map<String, String> readConfigFromHadoopXmlType(InputStream configFileStream) throws IOException {
ObjectReader reader = new XmlMapper().reader();
HadoopXml hadoopXml = reader.forType(HadoopXml.class).readValue(configFileStream);
Map<String, String> configMap = new HashMap<>();
for (HadoopXml.HadoopXmlProperty property : hadoopXml.getProperties()) {
configMap.put(property.getName(), property.getValue());
}
return configMap;
}
use of com.fasterxml.jackson.dataformat.xml.XmlMapper in project jocean-http by isdom.
the class MessageUtil method unserializeAsXml.
public static <T> T unserializeAsXml(final InputStream is, final Class<T> type) {
final XmlMapper mapper = new XmlMapper();
mapper.addHandler(new DeserializationProblemHandler() {
@Override
public boolean handleUnknownProperty(final DeserializationContext ctxt, final JsonParser p, final JsonDeserializer<?> deserializer, final Object beanOrClass, final String propertyName) throws IOException {
LOG.warn("UnknownProperty [{}], just skip", propertyName);
p.skipChildren();
return true;
}
});
try {
return mapper.readValue(is, type);
} catch (Exception e) {
LOG.warn("exception when parse as xml, detail: {}", ExceptionUtils.exception2detail(e));
return null;
}
}
use of com.fasterxml.jackson.dataformat.xml.XmlMapper in project cypher-for-gremlin by opencypher.
the class TckResultsComparator method getFeatures.
private static Features getFeatures(String reportPath) throws IOException {
File reportFile = new File(reportPath);
checkState(reportFile.exists(), format("File %s doesn't exist, but is required for TCK reports comparison.", reportPath));
ObjectMapper xmlMapper = new XmlMapper();
xmlMapper.setVisibility(PropertyAccessor.GETTER, JsonAutoDetect.Visibility.NONE);
xmlMapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
Feature value = xmlMapper.readValue(reportFile, Feature.class);
return new Features(new Feature[] { value });
}
use of com.fasterxml.jackson.dataformat.xml.XmlMapper in project tutorials by eugenp.
the class SimpleBeanForCapitalizedFields method whenJavaSerializedToXmlFile_thenCorrect.
@Test
public void whenJavaSerializedToXmlFile_thenCorrect() throws IOException {
XmlMapper xmlMapper = new XmlMapper();
xmlMapper.writeValue(new File("target/simple_bean.xml"), new SimpleBean());
File file = new File("target/simple_bean.xml");
assertNotNull(file);
}
Aggregations