On this Page

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.

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
        Example:


 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

    Example:

 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

    Example:

 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 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.
    Example:

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

    Example:

 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"]
    ]
}


Prerequisites

None.

Configuring Accounts

Accounts are not used with this Snap.

Configuring Views

InputThis Snap has exactly one document input view.
OutputThis Snap has exactly one document output view.
Error

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

Troubleshooting

  • None.

Support

  • Works in Ultra Pipelines.

Known Issues

  • None.

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

Pass Through
 


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

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.

Example

Source Path    | Operation | Target Path

$first_name       |    move       | $name.first

$phone_num     |    delete      |  

$names[2]        |    delete      | 

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

 

Default value none


Example Output


 Source Data Pass ThroughNull-safe access Source Path Operation Target Path Target Data


{
  "first_name" : "John",
  "last_name": "Smith"  
}


 YesDeselected

 $first_name

move

 $fname


[
{
"last_name":"Smith",
"fname":"John"
}
]



{
  "first_name" : "John",
  "last_name": "Smith"  
}


 [None] - new mapDeselected

 $first_name

move 

 $fname


[
{
"fname":"John"
}
]



{
  "first_name" : "John",
  "last_name": "Smith"  
}


 [None] - new listDeselected

 $first_name

move 

$[0].fname 


[
[
{
"fname":
"John"
}
]
]    



{
  "first_name" : "John",
  "last_name": "Smith"  
}


YesDeselected

$mid_name

move

 $middle

 Pipeline fails


{
  "first_name" : "John",
  "last_name": "Smith"  
}


 YesSelected

 $mid_name

move 

$middle 


[
{
"first_name":
"John"
"last_name":
"Smith"
"middle":
null
}
]



{
  "first_name" : "John",
  "last_name": "Smith"  
}


 YesDeselected

 $mid_name

 delete
 Pipeline fails


[  
   {  
      "person":{  
         "first":"John",
         "last":"Smith"
      },
      "id":2
   }
]


 YesDeselected

$person.first 

move 

$first 


[
  {
    "person":
  {
    "last":"Smith"
  }
  "id":2,
  "first":"John"
  }
]



{
  "first_name" : "John",
  "last_name": "Smith"  
}


 YesSelected$first_name
$first_name

move
move

$name1
$name2 


[
  {
    "last_name":"Smith",
    "name1":"John",
    "name2":"John"
  }
]



{
  "first_name" : "John",
  "mid_name" : "Alan",
  "last_name": "Smith" 
}


YesDeselected$mid_namedelete


[
  {
    "first_name":"John",
    "last_name":"Smith"
  }
]


Examples


See Also