> For the complete documentation index, see [llms.txt](https://worn.gitbook.io/json-function/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://worn.gitbook.io/json-function/functions/to-array.md).

# ToArray

[Github](https://github.com/aykutkardas/Json-Function) repository for your stars.

## Usage

#### Install

```bash
$ npm install json-function
```

#### Import

```javascript
import { toArray } from 'json-function';
```

#### Usage

Example Data

```javascript
const data = {
  'SpahhfW88GEcnVEXBkSB': {
    name: 'John'
  },
  'kDdjXxZWZwzKfYOyLUkE': {
    name: 'Mike'
  },
  'yPND1ItYbQXgoBXIAsz8': {
    name: 'Dan'
  }
};
```

Default key

```javascript
toArray(data);
```

Output

```javascript
[
  {
    uid: 'SpahhfW88GEcnVEXBkSB',
    name: 'John'
  },
  {
    uid: 'kDdjXxZWZwzKfYOyLUkE',
    name: 'Mike'
  },
  {
    uid:  'yPND1ItYbQXgoBXIAsz8',
    name: 'Dan'
  }
];
```

Use custom key

```javascript
toArray(data, { key: '_id_' });
```

Output

```javascript
[
  {
    _id_: 'SpahhfW88GEcnVEXBkSB',
    name: 'John'
  },
  {
    _id_: 'kDdjXxZWZwzKfYOyLUkE',
    name: 'Mike'
  },
  {
    _id_:  'yPND1ItYbQXgoBXIAsz8',
    name: 'Dan'
  }
];
```
