You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+18-19Lines changed: 18 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,14 +42,23 @@ Upgrading to v3 from v2? Check out the [upgrade guide](https://github.com/mrodri
42
42
*`callback` - A function of the form `function (err, csv)`;
43
43
* This function will receive any errors and/or the string of CSV generated.
44
44
*`options` - (Optional) A JSON document specifying any of the following key value pairs:
45
+
*`checkSchemaDifferences` - Boolean - Should all documents have the same schema?
46
+
* Default: `false`
47
+
* Note: An error will be thrown if some documents have differing schemas when this is set to `true`.
45
48
*`delimiter` - Document - Specifies the different types of delimiters
46
49
*`field` - String - Field Delimiter.
47
50
* Default: `,`
48
51
*`wrap` - String - Wrap values in the delimiter of choice (e.g. wrap values in quotes).
49
52
* Default: `"`
50
53
*`eol` - String - End of Line Delimiter.
51
54
* Default: `\n`
55
+
*`emptyFieldValue` - Any - Value that, if specified, will be substituted in for field values that are `undefined`, `null`, or an empty string.
56
+
* Default: none
52
57
*`excelBOM` - Boolean - Should a unicode character be prepended to allow Excel to open a UTF-8 encoded file with non-ASCII characters present.
58
+
*`keys` - Array - Specify the keys (as strings) that should be converted.
59
+
* Default: `null`
60
+
* If you have a nested object (ie. {info : {name: 'Mike'}}), then set this to ['info.name']
61
+
* If you want all keys to be converted, then specify ```null``` or don't specify the option to utilize the default.
53
62
*`prependHeader` - Boolean - Should the auto-generated header be prepended as the first line in the CSV?
54
63
* Default: `true`
55
64
*`sortHeader` - Boolean - Should the header keys be sorted in alphabetical order?
@@ -58,14 +67,6 @@ Upgrading to v3 from v2? Check out the [upgrade guide](https://github.com/mrodri
58
67
* Default: `false`
59
68
*`trimFieldValues` - Boolean - Should the field values be trimmed? (*in development*)
60
69
* Default: `false`
61
-
*`checkSchemaDifferences` - Boolean - Should all documents have the same schema?
62
-
* Default: `false`
63
-
* Note: Change this to `false` if some documents are missing certain fields and you still want to convert the data.
64
-
*`keys` - Array - Specify the keys (as strings) that should be converted.
65
-
* Default: `null`
66
-
* If you have a nested object (ie. {info : {name: 'Mike'}}), then set this to ['info.name']
67
-
* If you want all keys to be converted, then specify ```null``` or don't specify the option to utilize the default.
68
-
69
70
70
71
71
72
For examples, please refer to the [json2csv API Documentation (Link)](https://github.com/mrodrig/json-2-csv/wiki/json2csv-Documentation)
@@ -87,15 +88,15 @@ Available in version `2.2.0`, this functionality makes use of promises from the
87
88
*`eol` - String - End of Line Delimiter.
88
89
* Default: `\n`
89
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?
90
-
* Default: `false`
91
-
*`trimHeaderFields` - Boolean - Should the header fields be trimmed?
92
-
* Default: `false`
93
-
*`trimFieldValues` - Boolean - Should the field values be trimmed?
94
91
* Default: `false`
95
92
*`keys` - Array - Specify the keys (as strings) that should be converted.
96
93
* Default: `null`
97
94
* If you have a nested object (ie. `{info : {name: 'Mike'}}`), then set this to `['info.name']`
98
95
* If you want all keys to be converted, then specify `null` or don't specify the option to utilize the default.
96
+
*`trimHeaderFields` - Boolean - Should the header fields be trimmed?
97
+
* Default: `false`
98
+
*`trimFieldValues` - Boolean - Should the field values be trimmed?
99
+
* Default: `false`
99
100
100
101
For examples, please refer to the [csv2json API Documentation (Link)](https://github.com/mrodrig/json-2-csv/wiki/csv2json-Documentation)
101
102
@@ -109,18 +110,16 @@ Available in version `2.2.0`, this functionality makes use of promises from the
109
110
$ npm test
110
111
```
111
112
112
-
_Note_: This requires `mocha`, `should`, and `underscore`.
113
-
114
113
To see test coverage, please run:
115
114
```bash
116
115
$ npm run coverage
117
116
```
118
117
119
118
Current Coverage is:
120
119
```
121
-
Statements : 100% ( 258/258 )
122
-
Branches : 100% ( 124/124 )
123
-
Functions : 100% ( 49/49 )
120
+
Statements : 100% ( 261/261 )
121
+
Branches : 100% ( 131/131 )
122
+
Functions : 100% ( 47/47 )
124
123
Lines : 100% ( 256/256 )
125
124
```
126
125
@@ -130,13 +129,12 @@ Please find the updated list (relocated to the Wiki) here: [Frequently Asked Que
130
129
## Features
131
130
* Header Generation (per document keys)
132
131
* Allows for conversion of specific keys in both json2csv and csv2json via the options.keys parameter (as of 1.1.2)
133
-
*Verifies all documents have same schema (schema field order does not matter as of 1.1.0)
132
+
*Document schema verification functionality (field order is irrelevant) (as of 1.1.0)
134
133
* Supports sub-documents natively
135
134
* Supports arrays as document values for both json2csv and csv2json
136
135
* Custom ordering of columns (see F.A.Q. for more information)
137
136
* Ability to re-generate the JSON documents that were used to generate the CSV (including nested documents)
138
137
* Allows for custom field delimiters, end of line delimiters, etc.
139
-
* Promisifiable via bluebird's .promisify(<function>) and .promisifyAll(<object>) (as of 1.1.1)
140
138
* Wrapped value support for json2csv and csv2json (as of 1.3.0)
141
139
* Support for multiple different schemas (as of 1.4.0)
142
140
* Promisified versions of the functions are now available by default: json2csvAsync, csv2jsonAsync (as of 2.2.0)
@@ -145,3 +143,4 @@ Please find the updated list (relocated to the Wiki) here: [Frequently Asked Que
0 commit comments