JSON to XML
You need to convert one or more JSON files to a XML format.
Json
Example
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
Definition
| Property | Type | Required | Description |
|---|---|---|---|
| The name (or type) of the task | |||
| The unique name of the task in your job. It is used to reference this task in the workflow. | |||
| The functional description of this task in your job. | |||
The type of the task. It must be SUB_WORKFLOW. | |||
| : | true: the job continues if there is an error on this task. false: the job fails. | ||
| Input parameters of the task. See below |
Inputs
| Property | Type | Required | Description |
|---|---|---|---|
| mode | : | ||
| file | It can reference the output of a previous task, example: ${previous_taskReferenceName.output.file} , or a static file, example: file://assets/file.csv, or a user input, example: ${workflow.input.input_key}. | ||
| files | It can reference the output of a previous task, example: ${previous_taskReferenceName.output.files} , or a user input, example: ${workflow.input.input_key}. | ||
| request | A file that defines which files must be recovered. See the definition below. | ||
| json | A valide JSON to be processed. | ||
| : | Default: falseWhen set to true, the report generation is skipped and thus the report is not available in the output parameters. | ||
| : | Default: info It defines the log level to be recorded in the report. error < warning < info < debug |
Input request
Example
xml
<Json-To-Xml>
<File>
<Url>https://myaccount.blob.core.windows.net/files/data-1.json</Url>
</File>
<File>
<Url>https://myaccount.blob.core.windows.net/files/data-2.json</Url>
</File>
</Json-To-Xml>1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
Definition
Usually you need this after listing all files on sFTP with the FTP List task, and after having done the filtering of the file that must be retrieved in an Transform XSLT task. Use this method only if the other methods does not fit with your needs.
| XPath | Description | Occurs |
|---|---|---|
| Json-To-Xml | Root of the document | 1 |
| ./File | For each file. | 0..* |
| ./File/Url | The url of the file | 1 |
Outputs
| Property | Type | Description |
|---|---|---|
| file | An XML file as described below. | |
| allFilesTransformed | YES | NO. YES: all files have been transformed successfully. NO: at least one file has not been transformed. |
Output file
Example
xml
<Json-To-Xml>
<File>
<File-Name>file.json</File-Name>
<Data>
<Map>
<String key="title">New product</String>
<Number key="price">12.2</Number>
<Array key="colors">
<Map>
<String key="colorType">MAIN</String>
<String key="colorValue">red</String>
</Map>
<Map>
<String key="colorType">MAIN</String>
<String key="colorValue">green</String>
</Map>
</Array>
</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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Definition
| XPath | Description | Occurs |
|---|---|---|
| Json-To-Xml | Root of the document. | 1 |
| ./File | For each input file. | 1..* |
| ./File/File-Name | Original file name. | 1 |
| ./File/Data | The json converted as xml. | 1 |
How JSON values are named in Data
The content of Data follows the W3C XPath Functions 3.1 json-to-xml mapping, except that element names are capitalised to stay consistent with the other XML documents of the platform:
| JSON value | Element |
|---|---|
| object | <Map> |
| array | <Array> |
| string | <String> |
| number | <Number> |
| boolean | <Boolean> |
| null | <Null/> (empty element) |
A value held by an object property carries its property name in a key attribute (<String key="title">); values inside an array carry no key. Useful when writing an XSLT downstream: <Boolean> and <Null/> do not appear in the example above but are produced whenever the source JSON contains such values.
Limits and additional notes
- The limitation of the input file size is 100 Mb.
- The input file must be encoded in UTF-8