Data Factory > file-conversion-json-to-xml β
TL;DR;
This task converts a JSON content into an XML file.
Name:
Max execution time: 120 mins
Target β
Transform one or more JSON files (or string) into XML
Example of use in a job β
- Update items from reports available in JSON format
1. FTP Get Retrieves a list of JSON files from FTP
2. JSON To XML conversion converts retrieved files into an XML document
3. XSLT produces an items document
4. Import Items updates target items1
2
3
4
2
3
4
Inputs and Outputs β
json
{
"name": "file-conversion-json-to-xml",
"taskReferenceName": "json_to_xml",
"description": "The business description of the task",
"type": "SUB_WORKFLOW",
"optional": false,
"inputParameters": {
"mode": "FILE",
"file": "${previous_TaskReferenceName.output.file}"
}
}1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
Inputs β
TIP
If at least one task parameter (whether mandatory or not) is invalid, task execution is stopped and the returned status is FAILED. For example:
- The proposed value for the
fileproperty is invalid.
| Property | Description |
|---|---|
mode | Mandatory β Enum - FILE, FILES, REQUEST, JSONFILE: The file input is usedFILES: the transformation is applied to each of the files in filesREQUEST: the transformation is applied to each of the files in the XML request document (see below). |
json | Mandatory if mode = JSON - JsonThe JSON to be processed. |
file | Mandatory if mode = FILE - FileThe file to be processed. |
files | Mandatory if mode = FILES - Array of FileFiles to be processed. |
request | Mandatory if mode = REQUEST - FileFiles to be processed. |
Outputs β
TIP
The outputs of the task defined below are always available if the task completes its execution (status COMPLETED and FAILED). If the task is stopped before the end of its execution (if the task is canceled by the user for example - CANCELED status, or if it exceeds the authorized execution time - TIMED_OUT), the outputs are not available.
| Property | Description |
|---|---|
file | File An XML file, see below |
allFilesTransformed | Enum - YES, NOIf all files have been transformed: YES otherwise NO. |
DΓ©tails sur le document request β
xml
<Json-To-Xml>
<File>
<Url>https://prodstoragevazc.blob.core.windows.net/images/ee0c68fabf0a2b3c76b2643bff3cc215030f0caf.json</Url>
</File>
<File>
<Url>https://prodstoragevazc.blob.core.windows.net/images/7a597747dbc536e53eeb47760b5145d002b5bc25.json</Url>
</File>
</Json-To-Xml>1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
| XPath | Description | Occurrence |
|---|---|---|
Json-To-Xml | Root | 1 |
Json-To-Xml/File | For each file to be transformed | 0..* |
Json-To-Xml/File/Url | The url of the file to be transformed | 1 |
Details of documents in file and files output β
xml
<Json-To-Xml>
<File>
<File-Name>file.json</File-Name>
<Data>
<Map>
<Map key="processing_summary">
<Number key="processed">1</Number>
</Map>
<Array key="results">
<Map>
<Array key="messages">
<Map>
<String key="issue_type">RCVS_FAILED_TO_CONVERT_ATTRIBUTE_VALUE_TO_REQUIRED_TYPE</String>
<String key="description">The value '"0.1"' in the field 'value' for the attribute 'rtip_items_per_inner_pack' has the wrong type. The provided type is 'STRING' while the expected type is 'INT'.</String>
<String key="severity">ERROR</String>
<String key="attribute_name">rtip_items_per_inner_pack</String>
</Map>
</Array>
<String key="inbound_record_identifier">TITI</
String>
</Map>
</Array>
<String key="version">RC.1</String>
</Map>
</Data>
</File>
</Json-To-Xml>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Remarks:
- the format of the XML in the "Data" tag is as follows: https://www.w3.org/TR/xpath-functions-31/#json-to-xml-mapping
- The following elements have been modified to maintain consistency within our various XML documents
| The element... | Becomes |
|---|---|
| array | Array |
| map | Map |
| Boolean | Boolean |
| string | String |
| number | Number |
| nulll | Null |