Json Function
Search…
ToArray
Converts objects into meaningful sequences.
Github repository for your stars.

Usage

Install

1
$ npm install json-function
Copied!

Import

1
import { toArray } from 'json-function';
Copied!

Usage

Example Data
1
const data = {
2
'SpahhfW88GEcnVEXBkSB': {
3
name: 'John'
4
},
5
'kDdjXxZWZwzKfYOyLUkE': {
6
name: 'Mike'
7
},
8
'yPND1ItYbQXgoBXIAsz8': {
9
name: 'Dan'
10
}
11
};
Copied!
Default key
1
toArray(data);
Copied!
Output
1
[
2
{
3
uid: 'SpahhfW88GEcnVEXBkSB',
4
name: 'John'
5
},
6
{
7
uid: 'kDdjXxZWZwzKfYOyLUkE',
8
name: 'Mike'
9
},
10
{
11
uid: 'yPND1ItYbQXgoBXIAsz8',
12
name: 'Dan'
13
}
14
];
Copied!
Use custom key
1
toArray(data, { key: '_id_' });
Copied!
Output
1
[
2
{
3
_id_: 'SpahhfW88GEcnVEXBkSB',
4
name: 'John'
5
},
6
{
7
_id_: 'kDdjXxZWZwzKfYOyLUkE',
8
name: 'Mike'
9
},
10
{
11
_id_: 'yPND1ItYbQXgoBXIAsz8',
12
name: 'Dan'
13
}
14
];
Copied!
Last modified 2yr ago
Copy link
Contents
Usage