Stream JSON File Reader
Learn more about the component and how to use it.
Stream JSON File Reader reads a local JSON file, applies a JSON Path expression, returns a JSON structure according to the defined expressions and triggers subpipelines to process each message. The component is to be used for large files.
Take a look at the configuration parameters of the component:
- File Name: name of the local JSON file.
- JSON Path: JSON Path expression that determines how the JSON file stream reading will occur.
- Element Identifier: attribute that will be sent in case of errors.
- Parallel Execution Of Each Iteration: occurs in parallel with the loop execution.
- Fail On Error: when enabled, this parameter suspends the pipeline execution if there’s a severe occurence in the iteration structure, disabling its complete conclusion. The “Fail On Error” parameter activation doesn’t have any connection with the errors occurred in the components used for the construction of the subpipelines (onProcess and onException).
No specific input message is expected, but the existence of a JSON file in the pipeline local directory and the filling of the “File Name” and “JSON Path” fields for the file processing.
{
"total": 0,
"success": 0,
"failed": 0
}
- total: total number of processed lines
- success: total number of successfully processed lines
- failed: total number of lines whose process failed
IMPORTANT: when the lines are correctly processed, their respective subpipelines return { "success": true } for each of them.
The component throws an exception if the “File Name” doesn’t exist or can’t be read.
The files manipulation inside a pipeline occurs in a protected way. All the files can be accessed with a temporary directory only, where each pipeline key gives access to its own files set.
Stream JSON File Reader makes batch processing. To better understand the concept, read the article about Batch processing.
file.json
{
"products" : [
{
"product": "Chair",
"price": 20.75,
"tags": ["NEW", "FURNITURE"]
},
{
"product": "TV",
"price": 399.99,
"tags": ["NEW", "FURNITURE"]
},
{
"product": "Couch",
"price": 100,
"tags": ["NEW", "FURNITURE"]
},
{
"product": "Table",
"price": 78.99,
"tags": ["NEW", "FURNITURE"]
}
]
}
File Name: file.json
JSON Path: $.products[*]
{
"total": 4,
"success": 4,
"failed": 0
}
Each object inside the "products" array of the informed file will be processed in an independent way:
- First subflow
{"data": {
"product": "Chair",
"price": 20.75,
"tags": ["NEW", "FURNITURE"]
}}
- Second subflow
{"data": {
"product": "TV",
"price": 399.99,
"tags": ["NEW", "FURNITURE"]
}}
- Third subflow
{"data": {
"product": "Couch",
"price": 100,
"tags": ["NEW", "FURNITURE"]
}}
- Forth subflow
{"data": {
"product": "Table",
"price": 78.99,
"tags": ["NEW", "FURNITURE"]
}}
file.json
{
"products" : [
{
"product": "Chair",
"price": 20.75,
"tags": ["NEW", "FURNITURE"]
},
{
"product": "TV",
"price": 399.99,
"tags": ["NEW", "FURNITURE"]
},
{
"product": "Couch",
"price": 100,
"tags": ["NEW", "FURNITURE"]
},
{
"product": "Table",
"price": 78.99,
"tags": ["NEW", "FURNITURE"]
}
]
}
File Name: file.json
JSON Path: $.products[?(@.price < 80)]
{
"total": 2,
"success": 2,
"failed": 0
}
Each object inside the "products" array of the informed file will be processed in an independent way:
- First subflow
{"data": {
"product": "Chair",
"price": 20.75,
"tags": ["NEW", "FURNITURE"]
} }
- Second subflow
{"data": {
"product": "Table",
"price": 78.99,
"tags": ["NEW", "FURNITURE"]
}}
file.json
{
"products" : [
{
"product": "Chair",
"price": 20.75,
"tags": ["NEW", "FURNITURE"]
},
{
"product": "TV",
"price": 399.99,
"tags": ["NEW", "FURNITURE"]
},
{
"product": "Couch",
"price": 100,
"tags": ["NEW", "FURNITURE"]
},
{
"product": "Table",
"price": 78.99,
"tags": ["NEW", "FURNITURE"]
}
]
}
File Name: file.json
JSON Path: $.products[?(@.price < 80)].product
{
"total": 2,
"success": 2,
"failed": 0
}
Each object inside the "products" array of the informed file will be processed in an independent way:
- First subflow
{"data": "Chair" }
- Second subflow
{"data": "Table" }
Last modified 3mo ago