Socket
Socket
Sign inDemoInstall

json-2-csv

Package Overview
Dependencies
Maintainers
1
Versions
140
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-2-csv - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

.idea/compiler.xml

11

lib/json-2-csv.js

@@ -49,8 +49,11 @@ 'use strict';

if (keys.indexOf(key) > -1) { // If the keys contain the current key, then process the data
if (typeof value === 'object' && value !== null && typeof value.length === 'undefined') { // If we have an object
if (_.isArray(value)) { // We have an array of values
output.push((options.DELIMITER.WRAP || '') + '[' + value.join(options.DELIMITER.ARRAY) + ']' + (options.DELIMITER.WRAP || ''));
} else if (_.isDate(value)) { // If we have a date
console.log(value, _.isDate(value))
output.push(value.toString());
} else if (_.isObject(value)) { // If we have an object
output.push(convertData(value, _.keys(value))); // Push the recursively generated CSV
} else if (typeof value === 'object' && value !== null && typeof value.length === 'number') { // We have an array of values
output.push((options.DELIMITER.WRAP || '') + '[' + value.join(options.DELIMITER.ARRAY) + ']' + (options.DELIMITER.WRAP || ''));
} else {
value = value == null ? '' : value;
value = value == null ? '' : value.toString();
output.push((options.DELIMITER.WRAP || '') + value + (options.DELIMITER.WRAP || '')); // Otherwise push the current value

@@ -57,0 +60,0 @@ }

@@ -5,3 +5,3 @@ {

"description": "A JSON to CSV and CSV to JSON converter that natively supports sub-documents and auto-generates the CSV heading.",
"version": "1.0.6",
"version": "1.0.7",
"repository": {

@@ -8,0 +8,0 @@ "type": "git",

@@ -30,4 +30,4 @@ # Convert JSON to CSV or CSV to JSON

* `csv` - A string of CSV
* `callback` - A function of the form `function (err, array)`; This function will receive any errors and/or the array of JSON documents generated.
* `array` - An array of JSON documents to be converted to CSV.
* `callback` - A function of the form `function (err, csv)`; This function will receive any errors and/or the string of CSV generated.
* `options` - (Optional) A JSON document specifying any of {`DELIMITER`, `EOL`, `PARSE_CSV_NUMBERS`}

@@ -37,3 +37,3 @@ * `DELIMITER` - Document - Specifies the different types of delimiters

* `ARRAY` - String - Array Value Delimiter. Default: `';'`
* `WRAP` - String - Wrap values in the delimiter of choice (e.g. wrap values in quotes). Default: `''`
* `WRAP` - String - Wrap values in the delimiter of choice (e.g. wrap values in quotes). Default: `null`
* `EOL` - String - End of Line Delimiter. Default: `'\n'`

@@ -154,2 +154,6 @@ * `PARSE_CSV_NUMBERS` - Boolean - Should numbers that are found in the CSV be converted to numbers? Default: `false`

## Milestones
- Created: Apr 23, 2014
- 1K Downloads/Month: January 15, 2015
## TODO

@@ -156,0 +160,0 @@ - Use PARSE_CSV_NUMBERS option to actually convert numbers. Not currently implemented.

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