JSON-Repeat allows to inject new switch jobs for each element of a JSON array.
The respective array element is appended as a dataset to the associated job.
It is also possible to define an "Ungroup" key, which can be used to combine all these jobs again afterwards.
Switch Fall 2022 and higher.
Use one of our sample flows and drop a sample file into the flow.
This app requires one incoming connection - more incoming connections are allowed.
The app supports traffic light outgoing connections of the following types:
Property | Value | Description |
---|---|---|
Working Mode | enum [ JSON-File | JSON-Dataset ] | Defines the source of the input file |
JSON Path | String | Defines a JSON Path expression to the array of the JSON-dataset; we recommend using https://jsonpath.com/ to test your queries; checkout https://www.npmjs.com/package/jsonpath and https://www.npmjs.com/package/jsonpath-plus for more information |
Ungroup Key | String | Defines an Ungroup key, which can be used to combine all these jobs with the 'Assemble Job' element again afterwards. |
Dataset Name | String | Defines the dataset name of the resulting JSON |
Property | Value | Description |
---|---|---|
Master Dataset Name | String | Defines the name of the input dataset |
Input
Job-Name
: "sample.json"
{
"Account": {
"Account Name": "Firefly",
"Order": [
{
"OrderID": "order103",
"Product": [
{
"Product Name": "Bowler Hat",
"ProductID": 858383,
"Quantity": 2
},
{
"Product Name": "Trilby hat",
"ProductID": 858236
}
]
},
{
"OrderID": "order104",
"Product": [
{
"Product Name": "Bowler Hat",
"ProductID": 858383,
"Quantity": 4
},
{
"ProductID": 345664,
"Product Name": "Cloak",
"Quantity": 1
}
]
}
]
}
}
Configuration
JSON Path=$.Account.Order.*
Result
The JSON Path selects the order array and for each object a new job will be injected.
The resulting jobs will be named like <jobNameProper>_<index>.<ext>
and send to the log success connection.
Job 1:
test_0.pdf
Dataset:
{
"OrderID": "order103",
"Product": [
{
"Product Name": "Bowler Hat",
"ProductID": 858383,
"Quantity": 2
},
{
"Product Name": "Trilby hat",
"ProductID": 858236
}
]
}
Job 2:
test_1.pdf
Dataset:
{
"OrderID": "order104",
"Product": [
{
"Product Name": "Bowler Hat",
"ProductID": 858383,
"Quantity": 4
},
{
"ProductID": 345664,
"Product Name": "Cloak",
"Quantity": 1
}
]
}
This app uses two types of errors:
The following private data tags will be set if an error occurs:
Tag | Value | Type | Description |
---|---|---|
lastErrorElement | String | the name of the flow element |
lastErrorId | jsonRepeatError | |
lastErrorCode | Number | an error code that defines the type of error that occured |
lastErrorMessage | String | detailed error message |
<ungroupKey>.JobID | String | The unique name prefix of the incoming parent job |
<ungroupKey>.JobName | String | The name of the incoming parent job (without prefix) |
<ungroupKey>.NumFiles | Number | The length of the array that is iterated or in other words the total number of files injected in the flow for this parent job. |
<ungroupKey>.FileName | String | The name of this file as injected in the flow |
<ungroupKey>.FilePath | String | The relative path of this file within the parent job folder |
json.repeat.index | Number | The index of the current element / file |
Error Codes:
enum ERROR_CODES {
generalError = 0,
fileHandlingError = 1,
fileFormatError = 2,
conversionError = 3,
invalidParameterValue = 4,
parsingError = 5,
}