const array = ; // some array structure like belowconst origin = 'card': 1 'dates[0].date': 'dates[0].quantity': 3 'dates[1].date': 'dates[1].quantity': 4 'dates[2].date': 'dates[2].quantity': 4 card: 2 'dates[0].date': 'dates[0].quantity': 4 ; // applying unflattenconst result = array; // resultsconsole; /* result: [ { "card": 1, "dates": [ { "quantity": 3, "date": "2018-05-22T17:01:52.213Z" }, { "quantity": 4, "date": "2018-05-22T17:01:52.213Z" }, { "quantity": 4, "date": "2018-05-22T17:01:52.213Z" }, ] }, { "card": 2, "dates": [ { "quantity": 4, "date": "2018-05-22T17:01:52.213Z" } ] } ]*/
array-unflatten
0.0.3 • Public • PublishedPackage Sidebar
Install
npm i array-unflatten
Repository
Weekly Downloads
2
Version
0.0.3
License
ISC
Unpacked Size
2.36 kB
Total Files
5