Nav
You are viewing an older version of this section. Click here to navigate to the latest version.

Duplicating Data Structures in Map Format

Version 3.3.1 only

Use DataMapper to easily map data from an input file into a map format. (In DataMapper’s configuration, Map format is called Maps/List of Maps.) Rather than creating separate, identical input and output files between which you wish to map data, you can simply duplicate the content of your input file to use in the output pane.

After duplicating the data, you can edit — add, remove or rename fields — then map data between input and output fields.

This document assumes the reader is familiar with the DataMapper Transformer. Consult the DataMapper Transformer Reference document for details.

JSON to Map Format

The following example adds a new DataMapper transformer to a flow, then configures it to generate a duplicate of a JSON input file in the output pane.

Version 3.3.1 only

You can edit data structure definitions (i.e. fields) in an existing DataMapper transformer within the Input and Output panes of its DataMapper View. Consult Editing Metadata for details.

Creating the Input JSON File

  1. Open a new file in a text editor, then paste into it the following contents:

    
                 
              
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    
    {
      "type": "members",
      "id": "id0",
      "contacts": [
        {
          "name": "",
          "lastname": ""
        },
        {
          "name": "",
          "lastname": ""
        },
      ],
      "emergencyContacts": [
        {
          "name": "",
          "lastname": ""
        },
      ]
    }
  2. Save the file to a convenient location under a useful descriptive name such as Input.json. This file serves as the input JSON file for the example.

Adding DataMapper with a Duplicate Data Structure

The following procedure offers abbreviated steps for adding a DataMapper to a flow. For detailed instructions, consult the DataMapper Transformer Reference document.

  1. From the Transformers group in the Palette, drag a DataMapper building block to any location in your flow, except to the left of the flow’s message source).

  2. Double-click the DataMapper to open its configuration wizard.

  3. In the Name input box within the Data Mapping Flow pane, type a useful, descriptive name for your DataMapper, then click Next.

  4. In the Input section of the the Select Input and Output Type pane, use the drop-down menu next to the Type field to select JSON.

  5. Click the ellipsis symbol (…​) next to the Json sample field.

  6. Use the file browser to select the JSON file you created.

  7. In the Output section, use the drop-down menu next to the Type field to select Maps / List of Maps.

  8. Click Generate default under the Name field. DataMapper duplicates the data in the JSON input file in map format and changes the value of the Name field from outputMetadata to object (see image below).

    select_input_output

  9. Click Edit Fields to open the Edit Map Fields panel in preparation for editing the map-format output fields.

    edit_map_fields

Adding a Field to the Map Format Output

  1. In the Edit Map Fields panel, right-click contacts in the Output pane.

  2. Select Add Field to create a new field labelled field1 (see below, left).

  3. Click field1 (see below, right) to edit the name of the field, then press Enter.

    side-by-side

Alternative Method

  1. Click contacts to select the element.

  2. Click the (plus) icon in the upper-left corner of the Edit Map Fields panel to create a new field labelled field1.

  3. Click field1 to edit the name of the field, then press Enter.

Renaming a Field in the Map Format Output

  1. To rename a field, click the field name.

  2. Edit the field’s name, then press Enter.

Modifying Field Type in the Map Format Output

  1. To modify the type of a field, click the field’s type in the Type column.

  2. Use the drop-down menu to select a new field type.

    drop_down

  3. Click OK to save your changes and close the Edit Map Fields panel.

Deleting a Field in the Map Format Output

Use one of the following three methods to delete a field.

  • Click to select the field, then press Delete (not Backspace).

  • Right-click the field name, then select Remove from the drop-down menu.

  • Click to select the field, then press the red "X" icon in the upper-left corner of the Edit Map Fields panel.

In this topic: