Zips one of the following:

  • zips the output of fields together into an array of objects
  • zips the output of a single Table method into row objects
  • zips the output of sections together into an array of objects. For example, use this to zip multiple tables together.

Parameters

The following parameters are in the computed field's global Method parameter:

keyvaluedescription
id (required)zip
source_ids (required)array of field IDs in the current configOne of the following:

- the IDs of the fields to zip together.

- a single ID for a field that returns a table. Sensible returns an array of zipped row objects.

- the IDs of the section groups to zip together. Sensible returns a zipped section group containing all the fields from the source section groups. If there are identically named field IDs in the source section groups, Sensible falls back to outputting the IDs in the last section group listed in the source_id array.


Zips operate with the following precedence for source IDs:
- If at least one source field is a section group, Sensible outputs the section group and ignores all other types of sources.
- If at least one source is a table and there are no section group sources, Sensible outputs the first table ID and ignores all other sources.
- If the output of the source IDs are arrays, the Zip method joins them up to their maximum shared length. For example, if you zip arrays that have 4, 5, and 6 elements respectively, the zipped array has 4 elements. Examples of source IDs that output arrays include fields with "match: all" configured, and section groups.

Examples

Sections zip

For an example of zipping sections together, see Zip sections example.

Table zip

The following example shows using the Zip method to extract each row from a table of vehicles as a vehicle object.

Notes:

  • In order to filter out all column headings, the config specifies "type": "number" and "isRequired": true for the column col3_year_made .

  • To improve performance, the config specifies a Stop parameter. This ensures Sensible restricts table recognition to the relevant page area.

Config

{
  "fields": [
    {
      "id": "_insured_vehicles_table",
      "anchor": "insured vehicles",
      "type": "table",
      "method": {
        "id": "fixedTable",
        "columnCount": 4,
        "columns": [
          {
            "id": "col2_model",
            "index": 1
          },
          {
            "id": "col3_year_made",
            "index": 2,
            "type": "number",
            "isRequired": true
          }
        ],
        "stop": {
          "type": "startsWith",
          "text": "please"
        }
      }
    }
  ],
  "computed_fields": [
    {
      "id": "computed_insured_vehicles",
      "method": {
        "id": "zip",
        "source_ids": [
          "_insured_vehicles_table"
        ]
      }
    }
  ]
}

Example document

The following image shows the example PDF used with this example config:

Click to enlargeClick to enlarge

Example PDFDownload link

Output

{
  "_insured_vehicles_table": {
    "columns": [
      {
        "id": "col2_model",
        "values": [
          {
            "value": "Camry",
            "type": "string"
          },
          {
            "value": "CR-V",
            "type": "string"
          },
          {
            "value": "Golf",
            "type": "string"
          }
        ]
      },
      {
        "id": "col3_year_made",
        "values": [
          {
            "source": "2010",
            "value": 2010,
            "type": "number"
          },
          {
            "source": "2015",
            "value": 2015,
            "type": "number"
          },
          {
            "source": "2020",
            "value": 2020,
            "type": "number"
          }
        ]
      }
    ]
  },
  "computed_insured_vehicles": [
    {
      "col2_model": {
        "value": "Camry",
        "type": "string"
      },
      "col3_year_made": {
        "source": "2010",
        "value": 2010,
        "type": "number"
      }
    },
    {
      "col2_model": {
        "value": "CR-V",
        "type": "string"
      },
      "col3_year_made": {
        "source": "2015",
        "value": 2015,
        "type": "number"
      }
    },
    {
      "col2_model": {
        "value": "Golf",
        "type": "string"
      },
      "col3_year_made": {
        "source": "2020",
        "value": 2020,
        "type": "number"
      }
    }
  ]
}

Did this page help you?