Skip to content

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 can be any JSON, it's the items property of block (see below) that determines which array in the output of any upstream block—or in the input to the workflow, if it has been defined—is the input array 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: the JSON Splitter block splits an array in the output of any upstream block or in the input to the workflow and loops over the obtained objects, passing each of them to the next block in the context as its input.
    You choose the input array with the items drop-down in the Input area of the block properties pop-up.

    The drop-down list is divided in groups corresponding to upstream blocks and, possibly, the input to the workflow. Select the expand and collapse icons to the right of the group name to show or hide the sub-list of suitable output keys for that block.

    Note

    The drop-down list shows all the keys that can, potentially, be available, but the keys that are actually there when executing the workflow may be less.

    You can filter the list by typing at the top of it: the list will show only keys with matching names.

    To cancel the selection of the key, select No mapping from the list or, if you already chose a key, select Clear .

  • 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.