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

# Array or object: Flip keys and values

> Swaps the keys and values of an array or object.

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>;
};

Swaps the keys and values of an array or object. Each value in the input becomes a key in the result, and the key it used to sit under becomes its new value. Use this when you have a plain list of values and want to turn it into a lookup you can check by name, or when you need to know the position each value held in the original list.

Values have to become valid keys, so they must be plain text or whole numbers. If two items share the same value only the last one survives, because they would otherwise produce the same key.

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

## Fields

This mapper has no settings. Point it at the list or object you want to flip and it transforms whatever value it receives.

## Sample data

Input:

```json theme={null}
{ "tags": ["new", "sale", "featured"] }
```

Output:

```json theme={null}
{ "tags": { "new": 0, "sale": 1, "featured": 2 } }
```

Each tag has become a key, and its position in the original list (0, 1, 2) has become its value.

```json Configuration theme={null}
{
  "prototype": "list-flip",
  "parameters": {}
}
```
