Hi,
I tried to convert a JSON response from CouchDB
(.../_all_docs?include_docs=true) to XML, unfortunately it's incomplete
(contains only <total_rows>2</total_rows>).
It's reproducible with DOM4JProviderTest:
@Test
public void testReadJSONArrayConvertToXML() throws Exception {
final String json = "{\"total_rows\":2,\"offset\":0,\"rows\":[\n" +
"{\"id\":\"[email protected]\",\"value\":{\"rev\":\"1-2a93d664b63033378e7896a2d89d9e3a\"},\"doc\":{\"_id\":\"[email protected]\",\"_rev\":\"1-2a93d664b63033378e7896a2d89d9e3a\",\"email\":\"[email protected]\"}},\n"
+
"{\"id\":\"[email protected]\",\"value\":{\"rev\":\"1-00340568a529de9f0af61a41ed111158\"},\"doc\":{\"_id\":\"[email protected]\",\"_rev\":\"1-00340568a529de9f0af61a41ed111158\",\"email\":\"[email protected]\"}}\n"
+
"]}";
String str = convertJsonToXml(json);
// starts with the xml PI
assertTrue(str.contains("[email protected]"));
}
private String convertJsonToXml(final String xml) throws IOException {
DOM4JProvider p = new DOM4JProvider();
p.setProviders(new ProvidersImpl(createMessage()));
org.dom4j.Document dom = p.readFrom(org.dom4j.Document.class,
org.dom4j.Document.class,
new Annotation[]{}, MediaType.APPLICATION_JSON_TYPE, new
MetadataMap<String, String>(),
new ByteArrayInputStream(xml.getBytes("UTF-8")));
return dom.asXML();
}
How can I fix this? Should I open a JIRA issue for it?
Cheers
Dennis
--
View this message in context:
http://cxf.547215.n5.nabble.com/Incomplete-JSON-to-XML-conversion-by-DOM4JProvider-tp5748793.html
Sent from the cxf-user mailing list archive at Nabble.com.