@@ -665,7 +665,7 @@ const myCars = [
665665];
666666
667667const fields = [' carModel' , ' price' , ' colors' ];
668- const transforms = [unwind(' colors' )];
668+ const transforms = [unwind({ paths: [ ' colors' ] } )];
669669
670670const json2csvParser = new Parser({ fields, transforms });
671671const csv = json2csvParser.parse(myCars);
@@ -693,7 +693,7 @@ will output to console
693693You 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
698698const myCars = [
699699 {
@@ -740,7 +740,7 @@ const myCars = [
740740];
741741
742742const 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' ] } )];
744744const json2csvParser = new Parser({ fields, transforms });
745745const csv = json2csvParser.parse(myCars);
746746
@@ -764,7 +764,7 @@ will output to console
764764You can also unwind arrays blanking the repeated fields.
765765
766766```js
767- const { Parser } = require(' json2csv' );
767+ const { Parser, transforms: { unwind } } = require(' json2csv' );
768768
769769const myCars = [
770770 {
@@ -811,7 +811,7 @@ const myCars = [
811811];
812812
813813const 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
816816const json2csvParser = new Parser({ fields, transforms });
817817const csv = json2csvParser.parse(myCars);
@@ -876,8 +876,8 @@ const csv = json2csvParser.parse(myData);
876876
877877should 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(' __' )] });
881881const csv = json2csvParser.parse(myData);
882882` ` `
883883
0 commit comments