diff --git a/lib/json-2-csv.js b/lib/json-2-csv.js index ea651f0..f847915 100755 --- a/lib/json-2-csv.js +++ b/lib/json-2-csv.js @@ -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 diff --git a/package.json b/package.json index 261c12b..a178278 100755 --- a/package.json +++ b/package.json @@ -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" @@ -33,5 +33,6 @@ }, "engines": { "node": "*" - } + }, + "license": "MIT" }