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:

...

Overview

You can use this Snap to split a list of values into

...

separate JSON documents in its output view. It captures metadata and lineage information from the input document.

...

...

Snap Type

The JSON Parser Snap is a Transform-type Snap.

Prerequisites

...

...

None

...

.

Support

...

for Ultra Pipelines

Works in Ultra Pipelines.

...

Accounts are not used with this Snap.

...

Known Issues and Limitations

None.

Snap Views

Type

Format

Number of Views

Examples of Upstream and Downstream Snaps

Description

Input 

Document

 

 

  • Min: 1

  • Max: 1

  • Mapper

  • JSON Generator

JSON data to be split, in the form of a JSON array.

Output

Document

 

  • Min: 1

  • Max: 1

  • Mapper

  • Copy

  • File Reader

  • Filter

This 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, originalresolution, and stacktrace:

paste-code-macro
{
    "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: ... }

Error handling is a generic way to handle errors without losing data or failing the Snap execution. You can handle the errors that the Snap might encounter when running the Pipeline by choosing one of the following options from the When errors occur list under the Views tab:

  • Stop Pipeline Execution: Stops the current Pipeline execution if the Snap encounters an error.

  • Discard Error Data and Continue: Ignores the error, discards that record, and continues with the remaining records.

  • Route Error Data to Error View: Routes the error data to an error view without stopping the Snap execution.

Learn more about Error handling in Pipelines.

Snap Settings

Info
  • Asterisk (*): Indicates a mandatory field.

  • Suggestion icon ((blue star)): Indicates a list that is dynamically populated based on the configuration.

  • Expression icon ((blue star)): Indicates whether the value is an expression (if enabled) or a static value (if disabled). Learn more about Using Expressions in SnapLogic.

  • Add icon ((blue star)): Indicates that you can add fields in the field set.

  • Remove icon ((blue star)): Indicates that you can remove fields from the field set.

Field Name

Field Type

Description

Label*

...

Default Value: JSON Splitter

ExampleJSON Splitter

String

Specify 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 Path to Split*

...

Enter the JSON path manually. Alternatively, click the Suggestion Image Removed icon to view the list of paths and select the required path.

...

Default Value: None

Examples

  • $orders[*].orderlines[*]

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

...

String/Suggestion

Enter the JSON path manually. Alternatively, click the Suggestion (blue star) icon to view the list of paths and select the required path. Defines a path to the list that holds the document entries. Each entry of the list will be written out as a separate document.

Dynamic 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

...

Default ValueDeselected



Checkbox

Select this checkbox 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.
doc 1:

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

doc 2:

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


Enabling Include scalar parents will lead to:
doc 1: 

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


doc 2: 

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

Null-safe access

Default

...

Value:

...

Deselected

...

Null-safe access

...

Checkbox

Select this checkbox to skip invalid path definitions that are defined in the Include Paths property below.

...

If disabled when the path does not exist in the input view, the Snap displays a DataException.

...

Default value: Deselected

Include Paths

...


Select this checkbox 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:

paste-code-macro
languagejson
{
    "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
        }
    ],
}

Exclude List from Output Documents

Default Value: Deselected

Checkbox

Select

...

this checkbox to prevent the split list

...

from

...

being included in output documents.

...

Select this checkbox

...

to leverage the memory usage.

...

 

Show Null Values for Include Paths

...


Default Value: Deselected

Checkbox

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

Snap Execution

 

Default Value:

...

Multiexcerpt include macro
nameSnap Execution
pageAnaplan Read

...

Multiexcerpt include macro
nameSnap_Execution_Introduced
pageAnaplan Read

Examples

...

 Execute only
Example: Validate & Execute

Dropdown list

Select one of the three modes in which the Snap executes. Available options are:

  • Validate & Execute: Performs limited execution of the Snap, and generates a data preview during Pipeline validation. Subsequently, performs full execution of the Snap (unlimited records) during pipeline runtime.

  • Execute only: Performs full execution of the Snap during pipeline execution without generating preview data.

  • Disabled: Disables the Snap and all Snaps that are downstream from it.

Examples

For instance, there is a pipeline that contains File Reader, JSON Parser, and JSON Splitter Snaps.

The File Reader Snap 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 this

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

Snap Pack History

Insert excerpt
Transform Snap Pack
Transform Snap Pack
nopaneltrue