前端之家收集整理的这篇文章主要介绍了
XStream在将类转换为XML,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
public static String tran(WorkItem item){
XStream xstream = new XStream();
xstream.setMode(XStream.NO_REFERENCES);
xstream.alias("workitem",WorkItem.class);
return xstream.toXML(item);
}
public static String tranJson(WorkItem item){
XStream xstream = new XStream(new JsonHierarchicalStreamDriver());
xstream.setMode(XStream.NO_REFERENCES);
xstream.alias("workitem",WorkItem.class);
return xstream.toXML(item);
}
原文链接:https://www.f2er.com/xml/297848.html