11# json-2-csv
22** Convert JSON to CSV _ or_ CSV to JSON**
33
4- [ ![ Dependencies] ( https://img.shields.io/librariesio/release/npm/json-2-csv )] ( https://www.npmjs.org/package/json-2-csv )
5- [ ![ Downloads] ( https://img.shields.io/npm/dm/json-2-csv.svg )] ( https://www.npmjs.org/package/json-2-csv )
64[ ![ NPM version] ( https://img.shields.io/npm/v/json-2-csv.svg )] ( https://www.npmjs.org/package/json-2-csv )
5+ [ ![ Typings] ( https://img.shields.io/npm/types/json-2-csv )] ( https://www.npmjs.org/package/json-2-csv )
6+ [ ![ Downloads] ( https://img.shields.io/npm/dm/json-2-csv.svg )] ( https://www.npmjs.org/package/json-2-csv )
77[ ![ Minzipped Size] ( https://img.shields.io/bundlephobia/minzip/json-2-csv )] ( https://bundlephobia.com/result?p=json-2-csv )
88
99[ ![ Build Status] ( https://travis-ci.org/mrodrig/json-2-csv.svg?branch=master )] ( https://travis-ci.org/mrodrig/json-2-csv )
1010[ ![ Coverage Status] ( https://coveralls.io/repos/github/mrodrig/json-2-csv/badge.svg?branch=stable )] ( https://coveralls.io/github/mrodrig/json-2-csv?branch=stable )
1111[ ![ Maintainability] ( https://api.codeclimate.com/v1/badges/8c0cc3699d054fb77abe/maintainability )] ( https://codeclimate.com/github/mrodrig/json-2-csv/maintainability )
12- [ ![ Typings] ( https://img.shields.io/npm/types/json-2-csv )] ( https://www.npmjs.org/package/json-2-csv )
1312
1413This node module will convert an array of JSON documents to a CSV string.
1514Column headings will be automatically generated based on the keys of the JSON documents. Nested documents will have a '.' appended between the keys.
@@ -30,12 +29,13 @@ $ npm install @mrodrig/json-2-csv-cli
3029
3130## Upgrading?
3231
33- Upgrading to v3 from v2 ? Check out the [ upgrade guide] ( https://github.com/mrodrig/json-2-csv/blob/master/upgrade_guides/UPGRADE_2_to_3 .md ) .
32+ Upgrading to v4 from v3 ? Check out the [ upgrade guide] ( https://github.com/mrodrig/json-2-csv/blob/master/upgrade_guides/UPGRADE_3_to_4 .md ) .
3433
3534## Usage
3635
3736``` javascript
3837let converter = require (' json-2-csv' );
38+ const csv = await converter .json2csv (data, options);
3939```
4040or
4141``` javascript
@@ -45,11 +45,9 @@ Looking for examples? Check out the Wiki: [json-2-csv Wiki](https://github.com/m
4545
4646### API
4747
48- #### ` converter. json2csv(array, callback , options)`
48+ #### ` json2csv(array, options) `
4949
5050* ` array ` - An array of JSON documents to be converted to CSV.
51- * ` callback ` - A function of the form ` function (err, csv) ` ;
52- * This function will receive any errors and/or the string of CSV generated.
5351* ` options ` - (Optional) A JSON document specifying any of the following key value pairs:
5452 * ` checkSchemaDifferences ` - Boolean - Should all documents have the same schema?
5553 * Default: ` false `
@@ -146,14 +144,9 @@ Looking for examples? Check out the Wiki: [json-2-csv Wiki](https://github.com/m
146144
147145For examples, please refer to the [json2csv API Documentation (Link)](https://github.com/mrodrig/json-2-csv/wiki/json2csv-Documentation)
148146
149- #### Promisified Version: `converter.json2csvAsync(array, options)`
150-
151- Available in version `2.2.0`, this functionality makes use of promises from the `bluebird` module.
152-
153- #### `converter.csv2json(csv, callback, options)`
147+ #### `csv2json(csv, options)`
154148
155149* `csv` - A string of CSV
156- * `callback` - A function of the form `function (err, array)`; This function will receive any errors and/or the array of JSON documents generated.
157150* `options` - (Optional) A JSON document specifying any of the following key value pairs:
158151 * `delimiter` - Document - Specifies the different types of delimiters
159152 * `field` - String - Field Delimiter.
@@ -181,10 +174,6 @@ Available in version `2.2.0`, this functionality makes use of promises from the
181174
182175For examples, please refer to the [csv2json API Documentation (Link)](https://github.com/mrodrig/json-2-csv/wiki/csv2json-Documentation)
183176
184- #### Promisified Version: `csv2jsonAsync(csv, options)`
185-
186- Available in version `2.2.0`, this functionality makes use of promises from the `bluebird` module.
187-
188177### CLI
189178Note: As of `3.5.8`, the command line interface functionality has been pulled out to a separate package. Please be sure to
190179install the `@mrodrig/json-2-csv-cli` NPM package if you wish to use the CLI functionality shown below:
@@ -244,14 +233,6 @@ To see test coverage, please run:
244233$ npm run coverage
245234```
246235
247- Current Coverage is:
248- ```
249- Statements : 100% ( 286/286 )
250- Branches : 100% ( 166/166 )
251- Functions : 100% ( 73/73 )
252- Lines : 100% ( 280/280 )
253- ```
254-
255236## Frequently Asked Questions (FAQ)
256237Please find the updated list (relocated to the Wiki) here: [ Frequently Asked Questions (Link)] ( https://github.com/mrodrig/json-2-csv/wiki/FAQ )
257238
0 commit comments