本文整理匯總了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);
}