1
- # Convert JSON to CSV or CSV to JSON
1
+ # json-2-csv
2
+ ** Convert JSON to CSV _ or_ CSV to JSON**
2
3
3
- [ ![ Build Status] ( https://travis-ci.org/mrodrig/json-2-csv.svg?branch=master )] ( https://travis-ci.org/mrodrig/json-2-csv )
4
4
[ ![ Dependencies] ( https://img.shields.io/david/mrodrig/json-2-csv.svg?style=flat-square )] ( https://www.npmjs.org/package/json-2-csv )
5
+ [ ![ Build Status] ( https://travis-ci.org/mrodrig/json-2-csv.svg?branch=master )] ( https://travis-ci.org/mrodrig/json-2-csv )
5
6
[ ![ Downloads] ( http://img.shields.io/npm/dm/json-2-csv.svg )] ( https://www.npmjs.org/package/json-2-csv )
6
7
[ ![ NPM version] ( https://img.shields.io/npm/v/json-2-csv.svg )] ( https://www.npmjs.org/package/json-2-csv )
7
8
[ ![ Known Vulnerabilities] ( https://snyk.io/test/npm/json-2-csv/badge.svg )] ( https://snyk.io/test/npm/json-2-csv )
@@ -21,12 +22,12 @@ $ npm install json-2-csv
21
22
## Usage
22
23
23
24
``` javascript
24
- var converter = require (' json-2-csv' );
25
+ let converter = require (' json-2-csv' );
25
26
```
26
27
27
28
### API
28
29
29
- #### json2csv(array, callback, options)
30
+ #### ` converter. json2csv(array, callback, options)`
30
31
31
32
* ` array ` - An array of JSON documents to be converted to CSV.
32
33
* ` callback ` - A function of the form ` function (err, csv) ` ;
@@ -58,14 +59,16 @@ var converter = require('json-2-csv');
58
59
* Default: ` null `
59
60
* If you have a nested object (ie. {info : {name: 'Mike'}}), then set this to [ 'info.name']
60
61
* If you want all keys to be converted, then specify ``` null ``` or don't specify the option to utilize the default.
62
+
63
+
61
64
62
65
For examples, please refer to the [ json2csv API Documentation (Link)] ( https://github.com/mrodrig/json-2-csv/wiki/json2csv-Documentation )
63
66
64
- #### Promisified Version: json2csvPromisified(array, options).then(...).catch(...);
67
+ #### Promisified Version: ` converter. json2csvPromisified(array, options)`
65
68
66
69
Available in version ` 2.2.0 ` , this functionality makes use of promises from the ` bluebird ` module.
67
70
68
- #### csv2json(csv, callback, options)
71
+ #### ` converter. csv2json(csv, callback, options)`
69
72
70
73
* ` csv ` - A string of CSV
71
74
* ` callback ` - A function of the form ` function (err, array) ` ; This function will receive any errors and/or the array of JSON documents generated.
@@ -90,7 +93,7 @@ Available in version `2.2.0`, this functionality makes use of promises from the
90
93
91
94
For examples, please refer to the [ csv2json API Documentation (Link)] ( https://github.com/mrodrig/json-2-csv/wiki/csv2json-Documentation )
92
95
93
- #### Promisified Version: csv2jsonPromisified(csv, options).then(...).catch(...);
96
+ #### Promisified Version: ` csv2jsonPromisified(csv, options) `
94
97
95
98
Available in version ` 2.2.0 ` , this functionality makes use of promises from the ` bluebird ` module.
96
99
@@ -109,10 +112,10 @@ $ npm run coverage
109
112
110
113
Current Coverage is:
111
114
```
112
- Statements : 94.91 % ( 205/216 )
113
- Branches : 93.33 % ( 154/165 )
114
- Functions : 100% ( 37/37 )
115
- Lines : 95.59 % ( 195/204 )
115
+ Statements : 94.69 % ( 196/207 )
116
+ Branches : 93.55 % ( 145/155 )
117
+ Functions : 100% ( 34/34 )
118
+ Lines : 95.38 % ( 186/195 )
116
119
```
117
120
118
121
## Frequently Asked Questions (FAQ)
0 commit comments