本文整理汇总了Java中com.fasterxml.jackson.dataformat.xml.XmlMapper.writeValue方法的典型用法代码示例。如果您正苦于以下问题:Java XmlMapper.writeValue方法的具体用法?Java XmlMapper.writeValue怎么用?Java XmlMapper.writeValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.dataformat.xml.XmlMapper
的用法示例。
在下文中一共展示了XmlMapper.writeValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reportXml
import com.fasterxml.jackson.dataformat.xml.XmlMapper; //导入方法依赖的package包/类
public static void reportXml(Writer out, Report report) throws IOException {
XmlMapper mapper = new XmlMapper();
mapper.addMixIn(Report.class, ReportMixIn.class);
AnnotationIntrospector first = new SimpleTypesAsAttributesAnnotationIntrospector();
AnnotationIntrospector second = new JacksonXmlAnnotationIntrospector(false);
mapper.setAnnotationIntrospector(new AnnotationIntrospectorPair(first, second));
out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
mapper.writeValue(out, report);
}
示例2: stringify
import com.fasterxml.jackson.dataformat.xml.XmlMapper; //导入方法依赖的package包/类
public static String stringify(Object obj) {
XmlMapper mapper = newMapper();
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
mapper.writeValue(out, obj);
} catch (IOException ex) {
throw new RuntimeException(ex);
}
return out.toString();
}
示例3: writeIndexDataBeanFile
import com.fasterxml.jackson.dataformat.xml.XmlMapper; //导入方法依赖的package包/类
private void writeIndexDataBeanFile(IndexDataBean indexSummary, File path) throws Exception {
XmlMapper xmlMapper = new XmlMapper();
xmlMapper.configure(Feature.WRITE_XML_DECLARATION, true);
xmlMapper.writeValue(path, indexSummary);
}