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 55 },
66 "name" : " json-2-csv" ,
77 "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 " ,
99 "homepage" : " https://mrodrig.github.io/json-2-csv" ,
1010 "repository" : {
1111 "type" : " git" ,
Original file line number Diff line number Diff line change @@ -155,7 +155,7 @@ export const Json2Csv = function(options: FullJson2CsvOptions) {
155155 headerKey = headerKey . replace ( / \\ \. / g, '.' ) ;
156156 }
157157
158- return wrapFieldValueIfNecessary ( headerKey ) ;
158+ return headerKey ;
159159 } )
160160 . join ( options . delimiter . field ) ;
161161 return params ;
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ const csvFileConfig = [
1515 { key : 'nestedMissingField' , file : '../data/csv/nestedMissingField.csv' } ,
1616 { key : 'comma' , file : '../data/csv/comma.csv' } ,
1717 { key : 'quotes' , file : '../data/csv/quotes.csv' } ,
18+ { key : 'quotesHeader' , file : '../data/csv/quotesHeader.csv' } ,
1819 { key : 'quotesAndCommas' , file : '../data/csv/quotesAndCommas.csv' } ,
1920 { key : 'eol' , file : '../data/csv/eol.csv' } ,
2021 { key : 'assortedValues' , file : '../data/csv/assortedValues.csv' } ,
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ export default {
1616 nestedMissingField : require ( '../data/json/nestedMissingField' ) ,
1717 comma : require ( '../data/json/comma' ) ,
1818 quotes : require ( '../data/json/quotes' ) ,
19+ quotesHeader : require ( '../data/json/quotesHeader' ) ,
1920 quotesAndCommas : require ( '../data/json/quotesAndCommas' ) ,
2021 eol : require ( '../data/json/eol' ) ,
2122 assortedValues : require ( '../data/json/assortedValues' ) ,
Original file line number Diff line number Diff line change @@ -76,6 +76,11 @@ export function runTests() {
7676 assert . deepEqual ( json , jsonTestData . quotes ) ;
7777 } ) ;
7878
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+
7984 it ( 'should convert csv containing quotes and commas to json' , ( ) => {
8085 const json = csv2json ( csvTestData . quotesAndCommas ) ;
8186 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() {
7777 assert . equal ( csv , csvTestData . quotes ) ;
7878 } ) ;
7979
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+
8085 it ( 'should convert a document with fields containing quotes and commas to csv' , ( ) => {
8186 const csv = json2csv ( jsonTestData . quotesAndCommas ) ;
8287 assert . equal ( csv , csvTestData . quotesAndCommas ) ;
You can’t perform that action at this time.
0 commit comments