Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
Pradeep Mishra committed Jan 17, 2017
1 parent d48d3f4 commit 0dd3499
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ function toCSV(data, opts){
replaceNewLinePattern = new RegExp('\n|\r|' + opts.delimiter, 'g');
}


for(var i = 0; i < bigArrayLen; i++){
row = [ ];
for(var j = 0; j < keys.length; j++){
Expand All @@ -236,7 +237,6 @@ function toCSV(data, opts){
return csvData;
}


function _toCsv(data, table, parent, row, opt){
if(_dataType(data) === 'undefined'){
return _putData('', table, parent, row, opt);
Expand Down Expand Up @@ -317,8 +317,8 @@ function _getHeaders(headerType, table, opt){
function _getBigArrayLength(table){
var len = 0;
Object.keys(table).forEach(function(item){
if(Array.isArray(table[item]) && item.length > len){
len = item.length;
if(Array.isArray(table[item]) && table[item].length > len){
len = table[item].length;
}
});
return len;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "csvjson",
"description": "convert csv to json and json to csv",
"version": "4.0.0",
"version": "4.0.1",
"main": "./index.js",
"author": {
"name": "Pradeep Mishra"
Expand Down
22 changes: 22 additions & 0 deletions test/test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language",
"Acronym": "SGML",
"Abbrev": "ISO 8879:1986",
"GlossDef": {
"para": "A meta-markup language, used to create markup languages such as DocBook.",
"GlossSeeAlso": ["GML", "XML"]
},
"GlossSee": "markup"
}
}
}
}
}

0 comments on commit 0dd3499

Please sign in to comment.