XML to JSON (uv-t-xmlToJson):
This DPU transforms XML documents to equivalent JSON documents. The input and output is of type file.
|JSON Pretty Print||Generates JSON documents, outputted in human readable format instead of compact machine readable format|
|Cast to JSON primitives automatically||Data types of XML elements are automatically detected and casted into corresponding JSON primitive types|
|XML element path||The path of XML elements that should be parsed as a JSON array|
Inputs and Outputs
|filesInput||i||FilesDataUnit||XML documents to be transformed|
|filesOutput||i||FilesDataUnit||JSON documents produced from transformation|
XML Element to JSON Array
A sequence of XML elements with same element name can be considered as an array. However, there is no array structure in XML similar to JSON array, which means it is not prossible to decide if an element is actually an array with one object when there is only one element. Therefore, StAXON introduces some annotations to explicitly declare the XML elements that should be transformed into JSON arrays. Those annotations can be defined based on a XPath-like syntax
path ::= '/'? <localName> ('/' <localName>)*.
are transformed to:
By default with an annotation such as /alice/bob the result will become:
Particularly, the following chapters are relevant to this plugin: