How to handle duplicate xml tagged tags with Jackson

Can Jackson be used to handle duplicate xml tags based on their namespace?

The following is the JsonMappingException code: several fields representing the url property

private final ObjectMapper xmlMapper = new XmlMapper(); private static final String xml = "<example xmlns:test='http://test.com/'>" + "<test:url>www.namespace.com'</test:url>" + "<url>www.url.com'</url>" + "</example>"; @Test public void parseXml() throws Exception { Example example = xmlMapper.readValue(xml, Example.class); assert example.namespaceUrl.equals("www.namespace.com"); } public static class Example { @JsonProperty("url") public String namespaceUrl; @JsonProperty("url") public String url; } 

Thanks a bunch!

+4
source share
1 answer

There is currently no way to do this - you cannot use properties that differ only in namespace. This is not a fundamental limitation; those. with more work, it could be supported; but this is a current limitation.

+2
source

All Articles