Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

On this page

Table of Contents
maxLevel2
excludeOlder Versions|Additional Resources|Related Links|Related Information

Snap type:

Transform


Description:

This Snap splits a list of values into separate JSON documents in its output view.

  • Expected input: JSON data to be split, in the form of JSON array.


Prerequisites:

[None]


Support and limitations:

Works in Ultra Pipelines.

Account: 

Accounts are not used with this Snap.


Views:


InputThis Snap has exactly one document input view, where it gets the JSON data to be split.
OutputThis Snap has exactly one document output view, where it provides the JSON document data stream.
Error

This Snap has at most one document error view and produces zero or more documents in the view.

If the Snap fails during the operation, an error document is sent to the error view containing the fields error, reason, original, resolution, and stacktrace:

Code Block
{
    "error": "Json Splitter expects a list",
    "reason": "Found an object of type class java.lang.String",
    "original": {
      "prod": "p2",
      "price": "13"
    },
    "resolution": "The path $price needs to refer to a list in the incoming document",
    "stacktrace": "com.Snaplogic.Snap.api.SnapDataException: ... }



Settings

Label


Required. The name for the Snap. You can modify this to be more specific, especially if you have more than one of the same Snap in your pipeline.  

Json PathJSON Path


Required. Defines a path to the list that holds the document entries. Each entry of the list will be written out as a separate document.

Default value: None

Examples

  • $orders[*].orderlines[*]
  • $orders[*].orderlines[*].prod


Note
titleDynamic JSON Path

You can also include pipeline parameters in this property to be dynamic so that it picks values from the pipeline's properties. Use parentheses inside the square brackets to specify the pipeline parameter. For example, the JSON Path $orders[*].orderlines[*] can be written as $orders[*].[(_object)] where object is the pipeline parameter containing the value orderlines.


Include scalar parents



Allows to include scalar parents in each output document. 
Example:
input:


Code Block
{
    "add 1 data": [
        {
            "a": 1, "b": 2 }, {
            "a": 3, "b": 4 }
    ],
    "add 2 data": [
        {
            "a": 11, "b": 22 }, {
            "a": 33, "b": 44 }
    ],
    "id": 111 }


using the split path on ['add 1 data'] will create 2 output documents,
doc1:


Code Block
{
    "a": 1,
    "b": 2 }

doc 2:


Code Block
{
    "a": 3,
    "b": 4 }

Enabling Include scalar parents will lead to:
doc1: 

Code Block
{
    "a": 1,
    "b": 2,
    "id": 111 }

doc 2: 

Code Block
{
    "a": 3,
    "b": 4,
    "id": 111 }

Default value: Not selected


Null-safe access

optional 

Allow to skip invalid path definitions that are defined in the Include Paths property below. The Snap will throw a DataException if disabled when the path does not exist in the input view. 

Default value: Not selected

Include paths

optional

Allows to include objects from the input document in the resulting output document(s)
Example:
input same as above.

A path such as  ['add 2 data'] will include the object in the output documents:

doc1:

Code Block
{
    "a": 1,
    "b": 2,
    "id": 111,
    "add 2 data": [
        {
            "a": 11,
            "b": 22
        },
        {
            "a": 33,
            "b": 44
        }
    ],
}
doc2:
{
    "a": 3,
    "b": 4,
    "id": 111,
    "add 2 data": [
        {
            "a": 11,
            "b": 22
        },
        {
            "a": 33,
            "b": 44
        }
    ],
}


Show Null Values for Include Paths


Optional. Select the checkbox to show key-value entries of the null values for the objects added to the Include Paths field in the output documents. 

Default Value: N/A 

Multiexcerpt include macro
nameSnap Execution
pageAnaplan Read


Multiexcerpt include macro
nameSnap_Execution_Introduced
pageAnaplan Read

Examples


Assume a pipeline starts with File Reader + JSON Parser + JSON Splitter.

The File Reader reads a JSON file with the following contents:

Code Block
{
"customer":"ACME",
"orders":[
{
"ordernumber":"01", "orderdate":"20131122", "orderlines":[
{
"prod":"p1", "price":"23" }, {
"prod":"p2", "price":"13" }, {
"prod":"p3", "price":"231" }
], "city":"san mateo" }, {
"ordernumber":"02", "orderdate":"20131222", "orderlines":[
{
"prod":"w1", "price":"123" }, {
"prod":"e2", "price":"3" }, {
"prod":"q3", "price":"31" }
], "city":"burlingame" }
] }

If the JSON path in the JSON Splitter is set to: 

$orders[*].orderlines 

The data output would look something like: 

Code Block
[
  {
    "prod": "p1",
    "price": "23",
    "orderdate": "20131122",
    "ordernumber": "01",
    "customer": "ACME",
    "city": "san mateo" },
  {
    "prod": "p2",
    "price": "13",
    "orderdate": "20131122",
    "ordernumber": "01",
    "customer": "ACME",
    "city": "san mateo" },
  {
    "prod": "p3",
    "price": "231",
    "orderdate": "20131122",
    "ordernumber": "01",
    "customer": "ACME",
    "city": "san mateo" },
  {
    "prod": "w1",
    "price": "123",
    "orderdate": "20131222",
    "ordernumber": "02",
    "customer": "ACME",
    "city": "burlingame" },
  {
    "prod": "e2",
    "price": "3",
    "orderdate": "20131222",
    "ordernumber": "02",
    "customer": "ACME",
    "city": "burlingame" },
  {
    "prod": "q3",
    "price": "31",
    "orderdate": "20131222",
    "ordernumber": "02",
    "customer": "ACME",
    "city": "burlingame" }
]
 

See Also

Excerpt Include
Transform Snap Pack
Transform Snap Pack
nopaneltrue