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 1
1
{
2
2
"name" : " json-2-csv" ,
3
- "version" : " 1.0.6 " ,
3
+ "version" : " 1.0.7 " ,
4
4
"homepage" : " https://github.com/mrodrig/json-2-csv" ,
5
5
"moduleType" : [
6
6
" node"
Original file line number Diff line number Diff line change @@ -46,12 +46,15 @@ var convertData = function (data, keys) {
46
46
_ . each ( keys , function ( key , indx ) { // For each key
47
47
value = data [ key ] ; // Set the current data that we are looking at
48
48
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
52
50
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
53
56
} else {
54
- value = value == null ? '' : value ;
57
+ value = value == null ? '' : value . toString ( ) ;
55
58
output . push ( ( options . DELIMITER . WRAP || '' ) + value + ( options . DELIMITER . WRAP || '' ) ) ; // Otherwise push the current value
56
59
}
57
60
}
Original file line number Diff line number Diff line change 2
2
"author" : " mrodrig" ,
3
3
"name" : " json-2-csv" ,
4
4
"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 " ,
6
6
"repository" : {
7
7
"type" : " git" ,
8
8
"url" : " http://github.com/mrodrig/json-2-csv.git"
You can’t perform that action at this time.
0 commit comments