JSON Splitter
Overview
JSON Splitter is a splitter that runs its context for each item of an input array whose items are objects.
Input
The input to a JSON Splitter block must be a JSON with this structure:
{
"items": (array) Array of items to split,
}
Block properties
The properties of a JSON Splitter block are accessed by editing the block and are divided into these groups:
-
Basic properties:
- Block name
- Component version (read only)
- Block ID (read only)
-
Deployment:
- Timeout: execution timeout expressed in minutes (m) or seconds (s).
- Replicas: number of required instances.
- Consumer Number: number of threads of the consumer, the software module of the block that provides input to process by taking it from the block's work queue.
- Memory: required memory.
- CPU: thousandths of a CPU required (for example: 1000 = 1 CPU).
-
Input: this property corresponds to the top level key of the expected input JSON.
It is read-only—so only descriptive of the expected input—when the block is the first in a data flow and the workflow's input has not been explicitly described. In that case the workflow's input JSON must contain the expected key, with the same name and type.
They are editable otherwise, and must be set through fully automatic, assisted or manual input mapping.
- Output: read-only, this property is reminder of the structure of the output JSON that the splitter produces for each item of the input array.
Output
A JSON Splitter block produces as many items as the top-level objects contained in the input array. The block's context cycles over these items.
For example, if the input array is:
{
"topten": [
{
"author": "John Grisham",
"title": "The Pelican Brief",
"editor": "Doubleday",
"abstract": "In this legal thriller, law student Darby Shaw uncovers a conspiracy involving the assassination of two Supreme Court justices."
},
{
"author": "Stephen King",
"title": "Gerald's Game",
"editor": "Viking Press",
"abstract": "A woman is trapped and left to face her fears and memories of childhood trauma after her husband dies during a sex game."
},
{
"author": "Tom Clancy",
"title": "Without Remorse",
"editor": "Putnam",
"abstract": "Ex-Navy SEAL John Kelly seeks revenge against a drug lord after his pregnant wife is murdered."
},
{
"author": "Danielle Steel",
"title": "Mixed Blessings",
"editor": "Delacorte Press",
"abstract": "Three couples face the challenges of infertility, adoption, and marital issues in this heartwarming novel."
},
{
"author": "James Patterson",
"title": "Along Came a Spider",
"editor": "Little, Brown and Company",
"abstract": "Detective Alex Cross must catch a serial killer who targets Washington D.C. politicians and their children."
},
{
"author": "Nora Roberts",
"title": "Born in Ice",
"editor": "Jove",
"abstract": "The second installment in the 'Born In' trilogy follows Brianna Concannon as she struggles to save her family's bed and breakfast in Ireland."
},
{
"author": "Mary Higgins Clark",
"title": "Remember Me",
"editor": "Simon & Schuster",
"abstract": "When a plane crash kills her husband, Menley Nichols begins to believe that someone is trying to kill her as well."
},
{
"author": "John Grisham",
"title": "The Client",
"editor": "Doubleday",
"abstract": "Eleven-year-old Mark Sway hires lawyer Reggie Love to protect him from the mob after he witnesses a murder."
},
{
"author": "Michael Crichton",
"title": "Disclosure",
"editor": "Knopf",
"abstract": "A man is falsely accused of sexual harassment by his female boss in this gripping corporate thriller."
},
{
"author": "Robert James Waller",
"title": "Slow Waltz in Cedar Bend",
"editor": "Warner Books",
"abstract": "A college professor reflects on a past affair with an enigmatic woman while on a trip to Iowa."
}
]
}
the first output item will be:
{
"author": "John Grisham",
"title": "The Pelican Brief",
"editor": "Doubleday",
"abstract": "In this legal thriller, law student Darby Shaw uncovers a conspiracy involving the assassination of two Supreme Court justices."
}
The second item will be:
{
"author": "Stephen King",
"title": "Gerald's Game",
"editor": "Viking Press",
"abstract": "A woman is trapped and left to face her fears and memories of childhood trauma after her husband dies during a sex game."
}
The third item will be:
{
"author": "Tom Clancy",
"title": "Without Remorse",
"editor": "Putnam",
"abstract": "Ex-Navy SEAL John Kelly seeks revenge against a drug lord after his pregnant wife is murdered."
}
and so on.