Package net.obvj.confectory.mapper
Class JacksonXMLToJsonNodeMapper
- java.lang.Object
-
- net.obvj.confectory.mapper.JacksonJsonToObjectMapper<T>
-
- net.obvj.confectory.mapper.JacksonXMLToObjectMapper<com.fasterxml.jackson.databind.JsonNode>
-
- net.obvj.confectory.mapper.JacksonXMLToJsonNodeMapper
-
- All Implemented Interfaces:
Mapper<com.fasterxml.jackson.databind.JsonNode>
public class JacksonXMLToJsonNodeMapper extends JacksonXMLToObjectMapper<com.fasterxml.jackson.databind.JsonNode> implements Mapper<com.fasterxml.jackson.databind.JsonNode>
A specializedMapperthat loads the contents of a valid XMLSource(e.g.: file, URL, string) and converts it into aJsonNode, using Jackson'sXmlMapper.This allows fetching the contents using JSONPath expressions.
Because of differences between XML and JSON formats, there are certain limitations with Jackson's XML tree traversal support:
- Jackson cannot differentiate between an Object and an Array. Since XML lacks native structures to distinguish an object from a list of objects, Jackson will simply collate repeated elements into a single value.
- Since Jackson maps each XML element to a JSON node, it doesn't support mixed content (elements/attributes and text in same element).
Additional details can be found at Jackson's official documentation.
Notes:
- Conversion from XML to JSON may vary depending on the
Mapperimplementation. - Support for Jackson modules lookup is disabled for this type of mapper.
- Since:
- 0.3.0
- Author:
- oswaldo.bapvic.jr (Oswaldo Junior)
-
-
Constructor Summary
Constructors Constructor Description JacksonXMLToJsonNodeMapper()Builds a new XML-to-JSON mapper.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConfigurationHelper<com.fasterxml.jackson.databind.JsonNode>configurationHelper(com.fasterxml.jackson.databind.JsonNode jsonNode)-
Methods inherited from class net.obvj.confectory.mapper.JacksonXMLToObjectMapper
apply
-
Methods inherited from class net.obvj.confectory.mapper.JacksonJsonToObjectMapper
reloadModulesCache, resetModulesCache
-
-
-
-
Method Detail
-
configurationHelper
public ConfigurationHelper<com.fasterxml.jackson.databind.JsonNode> configurationHelper(com.fasterxml.jackson.databind.JsonNode jsonNode)
- Specified by:
configurationHelperin interfaceMapper<com.fasterxml.jackson.databind.JsonNode>- Overrides:
configurationHelperin classJacksonJsonToObjectMapper<com.fasterxml.jackson.databind.JsonNode>
-
-