Skip to content

Commit

Permalink
docs: fix unwind examples in README (#450)
Browse files Browse the repository at this point in the history
  • Loading branch information
juanjoDiaz authored Apr 1, 2020
1 parent 6c9b2c7 commit 8e54ea5
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ const myCars = [
];
const fields = ['carModel', 'price', 'colors'];
const transforms = [unwind('colors')];
const transforms = [unwind({ paths: ['colors'] })];
const json2csvParser = new Parser({ fields, transforms });
const csv = json2csvParser.parse(myCars);
Expand Down Expand Up @@ -693,7 +693,7 @@ will output to console
You can also unwind arrays multiple times or with nested objects.
```js
const { Parser } = require('json2csv');
const { Parser, transforms: { unwind } } = require('json2csv');
const myCars = [
{
Expand Down Expand Up @@ -740,7 +740,7 @@ const myCars = [
];
const fields = ['carModel', 'price', 'items.name', 'items.color', 'items.items.position', 'items.items.color'];
const transforms = [unwind(['items', 'items.items'])];
const transforms = [unwind({ paths: ['items', 'items.items'] })];
const json2csvParser = new Parser({ fields, transforms });
const csv = json2csvParser.parse(myCars);
Expand All @@ -764,7 +764,7 @@ will output to console
You can also unwind arrays blanking the repeated fields.
```js
const { Parser } = require('json2csv');
const { Parser, transforms: { unwind } } = require('json2csv');
const myCars = [
{
Expand Down Expand Up @@ -811,7 +811,7 @@ const myCars = [
];
const fields = ['carModel', 'price', 'items.name', 'items.color', 'items.items.position', 'items.items.color'];
const transforms = [unwind(['items', 'items.items'], true)];
const transforms = [unwind({ paths: ['items', 'items.items'], blankOut: true })];
const json2csvParser = new Parser({ fields, transforms });
const csv = json2csvParser.parse(myCars);
Expand Down Expand Up @@ -876,8 +876,8 @@ const csv = json2csvParser.parse(myData);
should be replaced by
```js
const { Parser, transforms: { unwind, flatten } } = require('json2csv');
const json2csvParser = new Parser({ transforms: [unwind(paths, true), flatten('__')] });
const { Parser, transform: { unwind, flatten } } = require('json2csv');
const json2csvParser = new Parser({ transforms: [unwind({ paths, blankOut: true }), flatten('__')] });
const csv = json2csvParser.parse(myData);
```
Expand Down

0 comments on commit 8e54ea5

Please sign in to comment.