55[ ![ Build Status] ( https://travis-ci.org/mrodrig/json-2-csv.svg?branch=master )] ( https://travis-ci.org/mrodrig/json-2-csv )
66[ ![ Downloads] ( http://img.shields.io/npm/dm/json-2-csv.svg )] ( https://www.npmjs.org/package/json-2-csv )
77[ ![ NPM version] ( https://img.shields.io/npm/v/json-2-csv.svg )] ( https://www.npmjs.org/package/json-2-csv )
8+ [ ![ Maintainability] ( https://api.codeclimate.com/v1/badges/8c0cc3699d054fb77abe/maintainability )] ( https://codeclimate.com/github/mrodrig/json-2-csv/maintainability )
89[ ![ Known Vulnerabilities] ( https://snyk.io/test/npm/json-2-csv/badge.svg )] ( https://snyk.io/test/npm/json-2-csv )
910
1011This node module will convert an array of JSON documents to a CSV string.
@@ -30,6 +31,10 @@ $ npm install json-2-csv
3031let converter = require (' json-2-csv' );
3132```
3233
34+ ## Upgrading?
35+
36+ 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 ) .
37+
3338### API
3439
3540#### ` converter.json2csv(array, callback, options) `
@@ -40,25 +45,22 @@ let converter = require('json-2-csv');
4045* ` options ` - (Optional) A JSON document specifying any of the following key value pairs:
4146 * ` delimiter ` - Document - Specifies the different types of delimiters
4247 * ` field ` - String - Field Delimiter.
43- * Default: ` ',' `
44- * ` array ` - String - Array Value Delimiter.
45- * Default: ` ';' `
48+ * Default: ` , `
4649 * ` wrap ` - String - Wrap values in the delimiter of choice (e.g. wrap values in quotes).
47- * Default: ` '' `
50+ * Default: ` " `
4851 * ` eol ` - String - End of Line Delimiter.
49- * Default: ` '\n' `
52+ * Default: ` \n `
53+ * ` excelBOM ` - Boolean - Should a unicode character be prepended to allow Excel to open a UTF-8 encoded file with non-ASCII characters present.
5054 * ` prependHeader ` - Boolean - Should the auto-generated header be prepended as the first line in the CSV?
5155 * Default: ` true `
5256 * ` sortHeader ` - Boolean - Should the header keys be sorted in alphabetical order?
5357 * Default: ` false `
54- * ` emptyFieldValue ` - String - Value for fields without data _ when not checking schemas_ .
55- * Default: ` 'null' `
5658 * ` trimHeaderFields ` - Boolean - Should the header fields be trimmed?
5759 * Default: ` false `
5860 * ` trimFieldValues ` - Boolean - Should the field values be trimmed? (* in development* )
5961 * Default: ` false `
6062 * ` checkSchemaDifferences ` - Boolean - Should all documents have the same schema?
61- * Default: ` true `
63+ * Default: ` false `
6264 * Note: Change this to ` false ` if some documents are missing certain fields and you still want to convert the data.
6365 * ` keys ` - Array - Specify the keys (as strings) that should be converted.
6466 * Default: ` null `
@@ -69,7 +71,7 @@ let converter = require('json-2-csv');
6971
7072For examples, please refer to the [ json2csv API Documentation (Link)] ( https://github.com/mrodrig/json-2-csv/wiki/json2csv-Documentation )
7173
72- #### Promisified Version: ` converter.json2csvPromisified (array, options) `
74+ #### Promisified Version: ` converter.json2csvAsync (array, options) `
7375
7476Available in version ` 2.2.0 ` , this functionality makes use of promises from the ` bluebird ` module.
7577
@@ -80,13 +82,13 @@ Available in version `2.2.0`, this functionality makes use of promises from the
8082* ` options ` - (Optional) A JSON document specifying any of the following key value pairs:
8183 * ` delimiter ` - Document - Specifies the different types of delimiters
8284 * ` field ` - String - Field Delimiter.
83- * Default: ` ',' `
84- * ` array ` - String - Array Value Delimiter.
85- * Default: ` ';' `
85+ * Default: ` , `
8686 * ` wrap ` - String - The character that field values are wrapped in.
87- * Default: ` '' `
87+ * Default: ` " `
8888 * ` eol ` - String - End of Line Delimiter.
89- * Default: ` '\n' `
89+ * Default: ` \n `
90+ * ` excelBOM ` - Boolean - Does the CSV contain a unicode character prepended in order to allow Excel to open a UTF-8 encoded file with non-ASCII characters present?
91+ * Default: `false`
9092 * ` trimHeaderFields ` - Boolean - Should the header fields be trimmed?
9193 * Default: ` false `
9294 * ` trimFieldValues ` - Boolean - Should the field values be trimmed?
@@ -98,7 +100,7 @@ Available in version `2.2.0`, this functionality makes use of promises from the
98100
99101For examples, please refer to the [ csv2json API Documentation (Link)] ( https://github.com/mrodrig/json-2-csv/wiki/csv2json-Documentation )
100102
101- #### Promisified Version: ` csv2jsonPromisified (csv, options)`
103+ #### Promisified Version: ` csv2jsonAsync (csv, options)`
102104
103105Available in version ` 2.2.0 ` , this functionality makes use of promises from the ` bluebird ` module.
104106
@@ -108,7 +110,7 @@ Available in version `2.2.0`, this functionality makes use of promises from the
108110$ npm test
109111```
110112
111- _ Note_ : This requires ` mocha ` , ` should ` , ` async ` , and ` underscore ` .
113+ _ Note_ : This requires ` mocha ` , ` should ` , and ` underscore ` .
112114
113115To see test coverage, please run:
114116``` bash
@@ -117,18 +119,18 @@ $ npm run coverage
117119
118120Current Coverage is:
119121```
120- Statements : 94.69 % ( 196/207 )
121- Branches : 93.55 % ( 145/155 )
122- Functions : 100% ( 34/34 )
123- Lines : 95.38 % ( 186/195 )
122+ Statements : 100 % ( 245/245 )
123+ Branches : 100 % ( 122/122 )
124+ Functions : 100% ( 48/48 )
125+ Lines : 100 % ( 243/243 )
124126```
125127
126128## Frequently Asked Questions (FAQ)
127129Please find the updated list (relocated to the Wiki) here: [ Frequently Asked Questions (Link)] ( https://github.com/mrodrig/json-2-csv/wiki/FAQ )
128130
129131## Features
130132* Header Generation (per document keys)
131- * Allows for conversion of specific keys in both json2csv and csv2json via the options.KEYS parameter (as of 1.1.2)
133+ * Allows for conversion of specific keys in both json2csv and csv2json via the options.keys parameter (as of 1.1.2)
132134* Verifies all documents have same schema (schema field order does not matter as of 1.1.0)
133135* Supports sub-documents natively
134136* Supports arrays as document values for both json2csv and csv2json
@@ -138,5 +140,6 @@ Please find the updated list (relocated to the Wiki) here: [Frequently Asked Que
138140* Promisifiable via bluebird's .promisify(<function >) and .promisifyAll(<object >) (as of 1.1.1)
139141* Wrapped value support for json2csv and csv2json (as of 1.3.0)
140142* Support for multiple different schemas (as of 1.4.0)
141- * Promisified versions of the functions are now available by default: json2csvPromisified, csv2jsonPromisified (as of 2.2.0)
143+ * Promisified versions of the functions are now available by default: json2csvAsync, csv2jsonAsync (as of 2.2.0)
142144* Nested quotes are escaped with an additional quote (per [ RFC 4180] ( https://tools.ietf.org/html/rfc4180 ) ) thanks to @eric-thelin (as of 2.3.0)
145+ * RFC 4180 Compliance (as of 3.0.0)
0 commit comments