Structural Transformations

The following structural transformations from the Structure Snap are supported in the Mapper Snap:

Move

A move is equivalent to a mapping without enabling pass-through. The source value is read from the input data and placed into the output data. Because Pass through is disabled, the input data is not copied to the output. Also, the source value is treated as an expression in the Mapper Snap, but it is a JSONPath in the Structure Snap. A jsonPath() function is available in the expression language to execute a JSONPath on a specific value. If you enable Pass through, then you should delete the old value.

Delete

Write a JSONPath in the source column and leave the target column blank.

Update

All cases for update can be handled by writing the appropriate JSONPath:

  • Update value: target path = $last_name
  • Update map: target = $address.first_name
  • Update list: target = $names[(value.length)] (places the new value at the end of the array)
  • Update list of maps: target = $customers[*].first_name (writes the value into the first_name field in all elements of the customers array)
  • Update list of lists: target = $lists_of_lists[*][(value.length)]

For performance reasons, the Mapper does not make a copy of any arrays or objects written to the Target Path. If you write the same array or object to more than one target path and plan to modify the object, make the copy yourself. For example, given the array $myarray and the following mappings:


                            $myarray -> $MyArray
                            [].concat($myarray) -> $OtherArray
                        
Future changes to either "$MyArray" or "$OtherArray" are in both arrays. So, make a copy of the array as shown below:
$myarray -> $MyArray [].concat($myarray) -> $OtherArray

This is true for objects, except you can make a copy with the .extend() method as shown below:


                            $myobject -> $MyObject $myobject.extend({}) -> $OtherObject