Skip to content

Commit

Permalink
Updating json-2-csv for #5
Browse files Browse the repository at this point in the history
  • Loading branch information
mrodrig committed Sep 16, 2014
1 parent 21647fe commit f13bd63
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/json-2-csv.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var retrieveSubHeading = function (heading, data) {
_.each(subKeys, function (subKey, indx) {
// If the given heading is empty, then we set the heading to be the subKey, otherwise set it as a nested heading w/ a dot
newKey = heading === '' ? subKey : heading + '.' + subKey;
if (typeof data[subKey] === 'object' && data[subKey] !== null && typeof data[subKey].length === 'undefined') { // If we have another nested document
if (typeof data[subKey] === 'object' && data[subKey] !== null && typeof data[subKey].length === 'undefined' && _.keys(data[subKey]).length > 0) { // If we have another nested document
subKeys[indx] = retrieveSubHeading(newKey, data[subKey]); // Recur on the subdocument to retrieve the full key name
} else {
subKeys[indx] = (options.DELIMITER.WRAP || '') + (newKey || '') + (options.DELIMITER.WRAP || ''); // Set the key name since we don't have a sub document
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"author": "mrodrig",
"name": "json-2-csv",
"description": "A JSON to CSV and CSV to JSON converter that natively supports sub-documents and auto-generates the CSV heading.",
"version": "0.1.5",
"version": "1.0.6",
"repository": {
"type": "git",
"url": "http://github.com/mrodrig/json-2-csv.git"
Expand Down Expand Up @@ -33,5 +33,6 @@
},
"engines": {
"node": "*"
}
},
"license": "MIT"
}

0 comments on commit f13bd63

Please sign in to comment.