JSON to XML
JSON to XML
Converts JSON data (e.g. responses to REST services) to XML, so that it can be further processed, e.g., by XSLT.
Name | Description |
---|---|
URL Prefix | Param which automatically replaces the defined URL with a whitespace |
Name | Type | DataUnit | Description | Required |
---|---|---|---|---|
input | i | FilesDataUnit | Input JSON files | |
output | o | FilesDataUnit | Produced XML data |
The following image shows a pipeline which performs an API request to PoolParty, transforms the JSON response to XML, and converts this XML into RDF/XML.
The configuration of the DPU can be seen in the image below.
The URL Prefix allows you to automatically replace a part of text/URL with a whitespace. This is useful when you work with custom attributes URLs as when these are converted to XML format the first slash from http:/ will then break in the text causing an output of unwanted XML data.
e.g.
JSON Response
{ "uri": "http://vocabulary.server.org/cocktails/0bbdca98-077b-48d1-99d6-47eca59c442c", "prefLabel": "Aviation", "http://vocabulary.server.org semantic-web.at/cocktail-ontology/image": [ "https://upload.wikimedia.org/wikipedia/commons/4/4f/Aviation_Cocktail.jpg" ] }
Unwanted XML Output
<root> <http:>https://upload.wikimedia.org/wikipedia/commons/4/4f/Aviation_Cocktail.jpg</http:> </root>
This is unwanted and is difficult to further transform due to the nature of needing to encode character breaks to handle this cause.
With the usage of the URL Prefix field we are able to have a better generated XML tag.
e.g.
Wanted XML Output
<root> <image>https://upload.wikimedia.org/wikipedia/commons/4/4f/Aviation_Cocktail.jpg</image> </root>