File tree Expand file tree Collapse file tree 8 files changed +28
-2
lines changed Expand file tree Collapse file tree 8 files changed +28
-2
lines changed Original file line number Diff line number Diff line change 5
5
},
6
6
"name" : " json-2-csv" ,
7
7
"description" : " A JSON to CSV and CSV to JSON converter that natively supports sub-documents and auto-generates the CSV heading." ,
8
- "version" : " 5.5.4 " ,
8
+ "version" : " 5.5.5 " ,
9
9
"homepage" : " https://mrodrig.github.io/json-2-csv" ,
10
10
"repository" : {
11
11
"type" : " git" ,
Original file line number Diff line number Diff line change @@ -155,7 +155,7 @@ export const Json2Csv = function(options: FullJson2CsvOptions) {
155
155
headerKey = headerKey . replace ( / \\ \. / g, '.' ) ;
156
156
}
157
157
158
- return wrapFieldValueIfNecessary ( headerKey ) ;
158
+ return headerKey ;
159
159
} )
160
160
. join ( options . delimiter . field ) ;
161
161
return params ;
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ const csvFileConfig = [
15
15
{ key : 'nestedMissingField' , file : '../data/csv/nestedMissingField.csv' } ,
16
16
{ key : 'comma' , file : '../data/csv/comma.csv' } ,
17
17
{ key : 'quotes' , file : '../data/csv/quotes.csv' } ,
18
+ { key : 'quotesHeader' , file : '../data/csv/quotesHeader.csv' } ,
18
19
{ key : 'quotesAndCommas' , file : '../data/csv/quotesAndCommas.csv' } ,
19
20
{ key : 'eol' , file : '../data/csv/eol.csv' } ,
20
21
{ key : 'assortedValues' , file : '../data/csv/assortedValues.csv' } ,
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ export default {
16
16
nestedMissingField : require ( '../data/json/nestedMissingField' ) ,
17
17
comma : require ( '../data/json/comma' ) ,
18
18
quotes : require ( '../data/json/quotes' ) ,
19
+ quotesHeader : require ( '../data/json/quotesHeader' ) ,
19
20
quotesAndCommas : require ( '../data/json/quotesAndCommas' ) ,
20
21
eol : require ( '../data/json/eol' ) ,
21
22
assortedValues : require ( '../data/json/assortedValues' ) ,
Original file line number Diff line number Diff line change @@ -76,6 +76,11 @@ export function runTests() {
76
76
assert . deepEqual ( json , jsonTestData . quotes ) ;
77
77
} ) ;
78
78
79
+ it ( 'should convert csv containing a header with quotes to json' , ( ) => {
80
+ const json = csv2json ( csvTestData . quotesHeader ) ;
81
+ assert . deepEqual ( json , jsonTestData . quotesHeader ) ;
82
+ } ) ;
83
+
79
84
it ( 'should convert csv containing quotes and commas to json' , ( ) => {
80
85
const json = csv2json ( csvTestData . quotesAndCommas ) ;
81
86
assert . deepEqual ( json , jsonTestData . quotesAndCommas ) ;
Original file line number Diff line number Diff line change
1
+ "author
2
+ (original)",quote
3
+ Carol Burnett,"""Only I can change my life. No one can do it for me."""
4
+ Professor,"Please submit all assignment names inside ""quotation"" marks (""), like ""Homework 7"""
Original file line number Diff line number Diff line change
1
+ [
2
+ {
3
+ "author\n (original)" : " Carol Burnett" ,
4
+ "quote" : " \" Only I can change my life. No one can do it for me.\" "
5
+ },
6
+ {
7
+ "author\n (original)" : " Professor" ,
8
+ "quote" : " Please submit all assignment names inside \" quotation\" marks (\" ), like \" Homework 7\" "
9
+ }
10
+ ]
Original file line number Diff line number Diff line change @@ -77,6 +77,11 @@ export function runTests() {
77
77
assert . equal ( csv , csvTestData . quotes ) ;
78
78
} ) ;
79
79
80
+ it ( 'should convert a document with header containing quotes to csv' , ( ) => {
81
+ const csv = json2csv ( jsonTestData . quotesHeader ) ;
82
+ assert . equal ( csv , csvTestData . quotesHeader ) ;
83
+ } ) ;
84
+
80
85
it ( 'should convert a document with fields containing quotes and commas to csv' , ( ) => {
81
86
const csv = json2csv ( jsonTestData . quotesAndCommas ) ;
82
87
assert . equal ( csv , csvTestData . quotesAndCommas ) ;
You can’t perform that action at this time.
0 commit comments