Skip to content

Commit 8e54ea5

Browse files
authored
docs: fix unwind examples in README (#450)
1 parent 6c9b2c7 commit 8e54ea5

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ const myCars = [
665665
];
666666
667667
const fields = ['carModel', 'price', 'colors'];
668-
const transforms = [unwind('colors')];
668+
const transforms = [unwind({ paths: ['colors'] })];
669669
670670
const json2csvParser = new Parser({ fields, transforms });
671671
const csv = json2csvParser.parse(myCars);
@@ -693,7 +693,7 @@ will output to console
693693
You can also unwind arrays multiple times or with nested objects.
694694
695695
```js
696-
const { Parser } = require('json2csv');
696+
const { Parser, transforms: { unwind } } = require('json2csv');
697697
698698
const myCars = [
699699
{
@@ -740,7 +740,7 @@ const myCars = [
740740
];
741741
742742
const fields = ['carModel', 'price', 'items.name', 'items.color', 'items.items.position', 'items.items.color'];
743-
const transforms = [unwind(['items', 'items.items'])];
743+
const transforms = [unwind({ paths: ['items', 'items.items'] })];
744744
const json2csvParser = new Parser({ fields, transforms });
745745
const csv = json2csvParser.parse(myCars);
746746
@@ -764,7 +764,7 @@ will output to console
764764
You can also unwind arrays blanking the repeated fields.
765765
766766
```js
767-
const { Parser } = require('json2csv');
767+
const { Parser, transforms: { unwind } } = require('json2csv');
768768
769769
const myCars = [
770770
{
@@ -811,7 +811,7 @@ const myCars = [
811811
];
812812
813813
const fields = ['carModel', 'price', 'items.name', 'items.color', 'items.items.position', 'items.items.color'];
814-
const transforms = [unwind(['items', 'items.items'], true)];
814+
const transforms = [unwind({ paths: ['items', 'items.items'], blankOut: true })];
815815
816816
const json2csvParser = new Parser({ fields, transforms });
817817
const csv = json2csvParser.parse(myCars);
@@ -876,8 +876,8 @@ const csv = json2csvParser.parse(myData);
876876
877877
should be replaced by
878878
```js
879-
const { Parser, transforms: { unwind, flatten } } = require('json2csv');
880-
const json2csvParser = new Parser({ transforms: [unwind(paths, true), flatten('__')] });
879+
const { Parser, transform: { unwind, flatten } } = require('json2csv');
880+
const json2csvParser = new Parser({ transforms: [unwind({ paths, blankOut: true }), flatten('__')] });
881881
const csv = json2csvParser.parse(myData);
882882
```
883883

0 commit comments

Comments
 (0)