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

# Convert data to arrays

> Transforms JSON objects to arrays.

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

Wraps the value found at a path in a list. Many systems expect a list of items even when there is only one, while a source might send a single object instead. Use this to find the value at the path you give and, if it is not already a list, place it inside a one-item list so the rest of your mapping can always loop over it. A value that is already a list is left as it is. You can optionally keep going into nested data and convert that too.

This documentation describes: [Schema](/schemas/transformer/convert-to-array)

## Fields

<FormField property="pattern" label="Base path" required uiPatterns="pattern">
  The path to the value you want to turn into a list, for example `order.items`. If the value there is a single object it becomes a list with that one object inside; if it is already a list it is left unchanged.
</FormField>

<FormField property="recursive" label="Recursive">
  An on/off toggle. Turn it on when the structure nests inside itself and you want every level converted, not just the top one. Off by default. When on, you also set the Recursive path below.
</FormField>

<FormField property="patternRecursive" label="Recursive path" required>
  Only shown when Recursive is on. The path to follow at each level when converting a structure that repeats itself, for example `children` for a menu where every item can have child items. Every level found along this path is converted to a list as well.
</FormField>

## Sample data

| Field     | Value         |
| --------- | ------------- |
| Base path | `order.items` |
| Recursive | off           |

Input:

```json theme={null}
{
    "order": {
        "items": { "sku": "A1", "qty": 2 }
    }
}
```

Output:

```json theme={null}
{
    "order": {
        "items": [
            { "sku": "A1", "qty": 2 }
        ]
    }
}
```

```json Configuration theme={null}
{
  "prototype": "convert-to-array",
  "parameters": {
    "pattern": "order.items"
  }
}
```
