Structure

Overview

This Snap modifies the structure of an incoming document. It can reuse the source document's data or create new data structures (list/map). When the Snap reuses source data, all untouched values will be preserved after all the operations are executed; so a source path can be moved multiple times. However, a target path cannot be the target of a move, otherwise the pipeline will fail. In addition, if a source path is deleted, then the path will not exist after it is executed. Paths can also be updated and the original value will not be deleted.
Note: If the source and target structures are the same, you do not need to use this Snap.
There are five cases for update:
Update value
the value is replaced
Source Data Pass Through Source Path Operation Target Path Target Data

                    {
                    "first_name": "Joe",
                    "last_name": "Smith"
                    }
                  
Yes $first_name update $last_name

                    {
                    "first_name": "Joe",
                    "last_name": "Joe"
                    }
                  
Update map
key in map is updated
Source Data Pass Through Source Path Operation Target Path Target Data

{
    first_name: "Joe",
    address: {
        street: "12 2nd Ave."
    }
}
                  
Yes $first_name update $address

{
    first_name: "Joe",
    address: {
        first_name: "Joe",
        street: "12 2nd Ave."
    }
}
                  
Update list
value is appended to list
Source Data Pass Through Source Path Operation Target Path Target Data
{
    first_name: "Joe",
    names: [
        "John", "Sally"
    ]
}
                  
Yes $first_name update $names

{
    first_name: "Joe",
    names: [
        "John", "Sally", "Joe"
    ]
}
                  
Update list of maps
value is appended to the end of each list
Note: If a list does not have all the same type scalar, map, or list, then the pipeline will fail.
Source Data Pass Through Source Path Operation Target Path Target Data
{
    first_name: "Joe",
    customers: [
        {
            last_name: "Smith",
            phone_num: "111-222-3333"
        },
        {
            last_name: "Smith",
            phone_num: "123-456-7890"
        }  
    ]
}
Yes $first_name update $customers
{
    first_name: "Joe",
    customers: [
        {
            first_name: "Joe",
            last_name: "Smith",
            phone_num: "111-222-3333"
        },
        {
            first_name: "Joe",
            last_name: "Smith",
            phone_num: "123-456-7890"
        }  
    ]
}               
Update list of lists
value is added to each map of the list
Note: If a list does not have all the same type scalar, map, or list, then the pipeline will fail.
Source Data Pass Through Source Path Operation Target Path Target Data
{
    first_name: "Joe",
    lists_of_lists: [
        [ "Sue", "Sally"],
        [ "John", "Sam"]
    ]
}
                  
Yes $first_name update $list_of_lists
{
    first_name: "Joe",
    lists_of_lists: [
        [ "Sue", "Sally", "Joe"],
        [ "John", "Sam", "Joe"]
    ]
}
                  

Snap views

View Description Examples of upstream and downstream Snaps
Input This Snap has exactly one document input view. JSON Generator
Output This Snap has exactly one document output view. Group By Fields

Mapper

Error

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. The available options are:

  • Stop Pipeline Execution Stops the current pipeline execution when an error occurs.
  • 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

Legend:
  • Expression icon (): Allows using JavaScript syntax to access SnapLogic Expressions to set field values dynamically (if enabled). If disabled, you can provide a static value. Learn more.
  • SnapGPT (): Generates SnapLogic Expressions based on natural language using SnapGPT. Learn more.
  • Suggestion icon (): Populates a list of values dynamically based on your Snap configuration. You can select only one attribute at a time using the icon. Type into the field if it supports a comma-separated list of values.
  • Upload : Uploads files. Learn more.
Learn more about the icons in the Snap settings dialog.
Field / Field set Type Description
Label String

Required. Specify a unique name for the Snap. Modify this to be more appropriate, especially if more than one of the same Snaps is in the pipeline.

Default value: Structure

Example: Structure Snap
Pass Through Dropdown list Required. Determine if data should be passed through or not. If set to yes, then the input data and its structure will be used. However, the output data structure can be changed by setting pass through to [None] - new map or [None] - new list. For example, if the input data is a key/value (map) structure, then the output structure can be changed to a list by setting pass through to [None] - new list and using target paths of list indices ($[0], $[1], $[2], etc).Options available include:
  • Yes
  • [None] - new map
  • [None] - new list

Default value: Yes

Mapping Table String/Expression Required. Source path, operation, and target path to use in the Snap. Source path is the JSONPath to move/delete. Operation is the type of operation to execute (move/delete). Target path is the JSONPath to write a value to in a move operation.

Default value: N/A

Example:

Source Path | Operation | Target Path

$first_name | move | $name.first

$phone_num | delete |

$names[2] | delete |

$names[*].first | move | $first_names

Snap execution Dropdown list
Choose 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.

Default value: Validate & Execute

Example: Execute only

Example Output

Table 1.
Source Data Pass through Null-safe access Source Path Operation Target Path Target Data
{
  "first_name" : "John",
  "mid_name" : "Alan",
  "last_name": "Smith"
}
Yes Deselected $mid_name delete
[
  {
    "first_name":"John",
    "last_name":"Smith"
  }
]
{
  "first_name" : "John",
  "last_name": "Smith" 
}
Yes Deselected $first_name move $fname
[
{
"last_name":"Smith",
"fname":"John"
}
]
{
  "first_name" : "John",
  "last_name": "Smith" 
}
[None]-new map Deselected $first_name move $fname
[
{
"fname":"John"
}
]
{
  "first_name" : "John",
  "last_name": "Smith" 
}
[None] - new list Deselected $first_name move $[0].fname
[
[
{
"fname":
"John"
}
]
]
{
  "first_name" : "John",
  "last_name": "Smith" 
}
Yes Deselected $mid_name move $middle Pipeline fails
{
  "first_name" : "John",
  "last_name": "Smith" 
}
Yes Selected $mid_name move $middle
[
{
"first_name":
"John"
"last_name":
"Smith"
"middle":
null
}
]
{
  "first_name" : "John",
  "last_name": "Smith" 
}
Yes Deselected $mid_name delete Pipeline fails
{
  "first_name" : "John",
  "last_name": "Smith" 
}
Yes Selected

$first_name

$first_name

move

$name1

$name1

[
  {
    "last_name":"Smith",
    "name1":"John",
    "name2":"John"
  }
]
[ 
   { 
      "person":{ 
         "first":"John",
         "last":"Smith"
      },
      "id":2
   }
]
Yes Deselected $person.first move $first
[
  {
    "person":
  {
    "last":"Smith"
  }
  "id":2,
  "first":"John"
  }
]