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

convert-csv-to-json

Package Overview
Dependencies
Maintainers
1
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

convert-csv-to-json - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

.idea/csvToJson.iml

2

package.json
{
"name": "convert-csv-to-json",
"version": "0.0.7",
"version": "0.0.8",
"description": "Convert CSV to JSON",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -1,2 +0,4 @@

# CSVtoJSON [![Build Status](https://travis-ci.org/iuccio/csvToJson.svg?branch=master)](https://travis-ci.org/iuccio/csvToJson)
# CSVtoJSON
[![Build Status](https://travis-ci.org/iuccio/csvToJson.svg?branch=master)](https://travis-ci.org/iuccio/csvToJson) [![Code Climate](https://codeclimate.com/github/iuccio/csvToJson/badges/gpa.svg)](https://codeclimate.com/github/iuccio/csvToJson)
Convert *csv* file to *JSON* file with Node.js.

@@ -80,3 +82,3 @@

#### Format property value by type
If you want that a number will be printed as a Numbert type and not as a String type, use:
If you want that a number will be printed as a Number type and not as a String type, use:
```js

@@ -94,3 +96,3 @@ csvToJson.formatValueByType().getJsonFromCsv(fileInputName)

"gender": "Male",
"age": 96 //instead of "96"
"age": 96
},

@@ -102,9 +104,17 @@ {

"gender": "Female",
"age": 32 //instead of "32"
"age": 32
}
]
```
The property **age** is printed as
```json
"age": 32
```
instead of
```json
"age": "32"
```
## License
CSVtoJSON is licensed under the GNU General Public License v3.0 [License](LICENSE).

@@ -12,3 +12,3 @@ 'use strict';

formatValueByType(){
formatValueByType() {
this.printValueFormatByType = true;

@@ -41,5 +41,6 @@ return this;

for (let i = 1; i < lines.length; i++) {
let currentLine = lines[i].split(fieldDelimiter);
let currentLine = lines[i].replace(/""/g, '"').split(fieldDelimiter);
console.log('CURRENT LINE\N ' + currentLine);
if (stringUtils.hasContent(currentLine)) {
jsonResult.push(this.buildJsonResult(headers,currentLine));
jsonResult.push(this.buildJsonResult(headers, currentLine));
}

@@ -50,3 +51,3 @@ }

buildJsonResult(headers,currentLine){
buildJsonResult(headers, currentLine) {
let jsonObject = {};

@@ -57,3 +58,3 @@ for (let j = 0; j < headers.length; j++) {

let value = currentLine[j];
if(this.printValueFormatByType){
if (this.printValueFormatByType) {
value = stringUtils.getValueFormatByType(currentLine[j]);

@@ -60,0 +61,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 not supported yet

Sorry, the diff of this file is not supported yet

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