如何优化此代码以从JSON转换为XML?

时间:2015-03-02 09:30:10

标签: java xml json performance

我使用此代码将JSON转换为XML:

DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document document = documentBuilder.newDocument();
document = standardJsonToXML(hierarchyData, document, null);
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
DOMSource source = new DOMSource(document);
StringWriter writer = new StringWriter();
StreamResult result = new StreamResult(writer);

transformer.transform(source, result);

return writer.toString();

我如何提高其表现?

0 个答案:

没有答案