File tree Expand file tree Collapse file tree 3 files changed +9
-6
lines changed Expand file tree Collapse file tree 3 files changed +9
-6
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " json-2-csv" ,
3- "version" : " 1.0.6 " ,
3+ "version" : " 1.0.7 " ,
44 "homepage" : " https://github.com/mrodrig/json-2-csv" ,
55 "moduleType" : [
66 " node"
Original file line number Diff line number Diff line change @@ -46,12 +46,15 @@ var convertData = function (data, keys) {
4646 _ . each ( keys , function ( key , indx ) { // For each key
4747 value = data [ key ] ; // Set the current data that we are looking at
4848 if ( keys . indexOf ( key ) > - 1 ) { // If the keys contain the current key, then process the data
49- if ( typeof value === 'object' && value !== null && typeof value . length === 'undefined' ) { // If we have an object
50- output . push ( convertData ( value , _ . keys ( value ) ) ) ; // Push the recursively generated CSV
51- } else if ( typeof value === 'object' && value !== null && typeof value . length === 'number' ) { // We have an array of values
49+ if ( _ . isArray ( value ) ) { // We have an array of values
5250 output . push ( ( options . DELIMITER . WRAP || '' ) + '[' + value . join ( options . DELIMITER . ARRAY ) + ']' + ( options . DELIMITER . WRAP || '' ) ) ;
51+ } else if ( _ . isDate ( value ) ) { // If we have a date
52+ console . log ( value , _ . isDate ( value ) )
53+ output . push ( value . toString ( ) ) ;
54+ } else if ( _ . isObject ( value ) ) { // If we have an object
55+ output . push ( convertData ( value , _ . keys ( value ) ) ) ; // Push the recursively generated CSV
5356 } else {
54- value = value == null ? '' : value ;
57+ value = value == null ? '' : value . toString ( ) ;
5558 output . push ( ( options . DELIMITER . WRAP || '' ) + value + ( options . DELIMITER . WRAP || '' ) ) ; // Otherwise push the current value
5659 }
5760 }
Original file line number Diff line number Diff line change 22 "author" : " mrodrig" ,
33 "name" : " json-2-csv" ,
44 "description" : " A JSON to CSV and CSV to JSON converter that natively supports sub-documents and auto-generates the CSV heading." ,
5- "version" : " 1.0.6 " ,
5+ "version" : " 1.0.7 " ,
66 "repository" : {
77 "type" : " git" ,
88 "url" : " http://github.com/mrodrig/json-2-csv.git"
You can’t perform that action at this time.
0 commit comments