Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

json2csv

Package Overview
Dependencies
Maintainers
3
Versions
104
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json2csv - npm Package Compare versions

Comparing version 3.7.3 to 3.8.0

24

CHANGELOG.md

@@ -5,8 +5,28 @@ # Change Log

<a name="3.7.4"></a>
## [3.7.4](https://github.com/zemirco/json2csv/compare/v3.7.1...v3.7.4) (2016-12-08)
<a name="3.8.1"></a>
## [3.8.1](https://github.com/zemirco/json2csv/compare/v3.8.0...v3.8.1) (2017-07-03)
<a name="3.8.0"></a>
# [3.8.0](https://github.com/zemirco/json2csv/compare/v3.7.3...v3.8.0) (2017-07-03)
### Bug Fixes
* **docs:** Add a coma in the ReadMe example ([#181](https://github.com/zemirco/json2csv/issues/181)) ([abeb820](https://github.com/zemirco/json2csv/commit/abeb820))
### Features
* Preserve new lines in cells with option preserveNewLinesInCells ([#91](https://github.com/zemirco/json2csv/issues/91)) ([#171](https://github.com/zemirco/json2csv/issues/171)) ([187b701](https://github.com/zemirco/json2csv/commit/187b701))
<a name="3.7.3"></a>
## [3.7.3](https://github.com/zemirco/json2csv/compare/v3.7.1...v3.7.3) (2016-12-08)
### Bug Fixes
* **jsdoc:** JSDoc Editting ([#155](https://github.com/zemirco/json2csv/issues/155)) ([76075d6](https://github.com/zemirco/json2csv/commit/76075d6))

@@ -13,0 +33,0 @@ * **ts:** Fix type definition ([#154](https://github.com/zemirco/json2csv/issues/154)) ([fae53a1](https://github.com/zemirco/json2csv/commit/fae53a1))

24

lib/json2csv.js

@@ -22,3 +22,3 @@ /**

* @property {String} [quotes='"'] - quotes around cell values and column names
* @property {String} [doubleQuotes='"""'] - the value to replace double quotes in strings
* @property {String} [doubleQuotes='""'] - the value to replace double quotes in strings
* @property {Boolean} [hasCSVColumnTitle=true] - determines whether or not CSV file will contain a title column

@@ -228,4 +228,16 @@ * @property {String} [eol=''] - it gets added to each row of data

if (val !== undefined) {
if (params.preserveNewLinesInValues && typeof val === 'string') {
val = val
.replace(/\n/g, '\u2028')
.replace(/\r/g, '\u2029');
}
var stringifiedElement = JSON.stringify(val);
if (params.preserveNewLinesInValues && typeof val === 'string') {
stringifiedElement = stringifiedElement
.replace(/\u2028/g, '\n')
.replace(/\u2029/g, '\r');
}
if (typeof val === 'object') stringifiedElement = JSON.stringify(stringifiedElement);

@@ -251,4 +263,4 @@

//remove last delimeter
line = line.substring(0, line.length - 1);
//remove last delimeter by its length
line = line.substring(0, line.length - params.del.length);
//Replace single quotes with double quotes. Single quotes are preceeded by

@@ -279,3 +291,3 @@ //a backslash. Be careful not to remove backslash content from the string.

var dataRows = params.data;
if (params.unwindPath) {

@@ -286,3 +298,3 @@ dataRows = [];

var isArr = Array.isArray(unwindArray);
if (isArr && unwindArray.length) {

@@ -303,4 +315,4 @@ unwindArray.forEach(function(unwindEl) {

}
return dataRows;
}
{
"name": "json2csv",
"preferGlobal": "true",
"version": "3.7.4",
"version": "3.8.1",
"description": "Convert JSON to CSV",

@@ -6,0 +6,0 @@ "keywords": [

@@ -49,2 +49,3 @@ # json2csv

- If field is not exist in object then the field value in CSV will be empty.
- Preserve new lines in values. Should be used with \r\n line endings for full compatibility with Excel.

@@ -63,3 +64,3 @@ ## Use as a module

- `quotes` - String, quotes around cell values and column names. Defaults to `"` if not specified.
- `doubleQuotes` - String, the value to replace double quotes in strings. Defaults to 3x`quotes` (for example `"""`) if not specified.
- `doubleQuotes` - String, the value to replace double quotes in strings. Defaults to 2x`quotes` (for example `""`) if not specified.
- `hasCSVColumnTitle` - Boolean, determines whether or not CSV file will contain a title column. Defaults to `true` if not specified.

@@ -72,2 +73,3 @@ - `eol` - String, it gets added to each row of data. Defaults to `` if not specified.

- `includeEmptyRows` - Boolean, includes empty rows. Defaults to `false`.
- `preserveNewLinesInValues` - Boolean, preserve \r and \n in values. Defaults to `false`.
- `callback` - `function (error, csvString) {}`. If provided, will callback asynchronously. Only supported for compatibility reasons.

@@ -98,3 +100,3 @@

// Support pathname -> pathvalue
'simplepath' // equivalent to {value:'simplepath'}
'simplepath', // equivalent to {value:'simplepath'}
'path.to.value' // also equivalent to {label:'path.to.value', value:'path.to.value'}

@@ -101,0 +103,0 @@ ]

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc