> ## Documentation Index
> Fetch the complete documentation index at: https://docs.alumio.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Map array or object items

> Performs actions on arrays and objects.

export const FormField = ({property, label, required = false, diType, uiPatterns, children}) => {
  const patterns = Array.isArray(uiPatterns) ? uiPatterns : uiPatterns ? [uiPatterns] : [];
  return <div style={{
    margin: '1.5rem 0'
  }}>
      <div style={{
    display: 'flex',
    alignItems: 'baseline',
    flexWrap: 'wrap',
    gap: '0.5rem',
    marginBottom: '0.25rem'
  }}>
        <strong>{label}</strong>
        <span style={{
    fontSize: '0.7rem',
    fontWeight: 600,
    textTransform: 'uppercase',
    letterSpacing: '0.04em',
    color: required ? '#6241f5' : '#6b7280'
  }}>
          {required ? 'Required' : 'Optional'}
        </span>
      </div>

      <div>{children}</div>

      {diType || patterns.length > 0 ? <p style={{
    fontSize: '0.85rem',
    color: '#6b7280',
    marginBottom: 0
  }}>
          {diType ? <>
              See the <a href={`/references/${diType}`}>{diType}</a> reference.{' '}
            </> : null}
          {patterns.length > 0 ? <>
              Accepts a <a href={`/documentation/placeholders-and-patterns/patterns#${patterns[0]}`}>pattern</a>.
            </> : null}
        </p> : null}
    </div>;
};

Reshapes a whole list or object in one step. You point at the collection you want to work on with an accessor, then apply one or more conversions to it as a set rather than item by item. Whatever the conversions return replaces the original: any entry they drop is removed, and the rest are written back. Use this for jobs that act on the collection as a whole, such as sorting it, reversing it, removing duplicates, or swapping its keys and values.

This documentation describes: [Schema](/schemas/transformer/list-mapper)

## Fields

<FormField property="accessor" label="Accessor" required diType="accessor">
  Selects the list or object the conversions work on, taken as a whole set of values. See [Accessors](/references/accessor) for the available options.
</FormField>

<FormField property="mappers" label="Mappers" diType="mapper">
  The list of conversions applied to the whole collection, such as sorting it, reversing it, or swapping its keys and values. Add several and they run in the order you list them, each working on the result of the one before. The result they produce replaces the collection, so any entry left out is removed from the data. Leave it empty to make no change.
</FormField>

## Sample data

| Field    | Value                                              |
| -------- | -------------------------------------------------- |
| Accessor | Pattern accessor matching `*` (all top-level keys) |
| Mappers  | Array or object: Flip keys and values              |

Input:

```json theme={null}
{
    "color": "grey",
    "size": "M",
    "material": "wool"
}
```

Output:

```json theme={null}
{
    "grey": "color",
    "M": "size",
    "wool": "material"
}
```

The conversion swapped each key with its value across the whole set: the old field names became values, and the old values became the new field names.

```json Configuration theme={null}
{
  "prototype": "list-mapper",
  "parameters": {
    "accessor": {
      "prototype": "pattern",
      "parameters": { "pattern": "*" }
    },
    "mappers": [
      { "prototype": "list-flip", "parameters": {} }
    ]
  }
}
```
