json-2-csv icon indicating copy to clipboard operation
json-2-csv copied to clipboard

why json to csv adds `\` before `.` in headers

Open moHaHa opened this issue 1 year ago • 0 comments

Background Information

  • Module Version:
  • Node/Browser Version:

The issue I'm reporting is with:

  • [x] json2csv
  • [ ] csv2json

I have...

  • [x] searched to see if an issue has already been reported.
  • [x] verified that my JSON/CSV data is valid (using something like http://jsonlint.com or https://csvlint.io/).
  • [ x tried upgrading to the latest version of json-2-csv (since the issue may already be fixed).

Expected Behavior

Actual Behavior

Data Sample

CSV:

id,minRef,name*,reference,facilityType*,facilityGroup,facilityGroup name,location\.country,location\.city,location\.location,location\.longitude,location\.latitude,estimatedCostLabourPerMonth,estimatedCostMaterialPerMonth,constructionDate,isActive*
,,name,,facility type,,,location.country,,,,,,,,TRUE

(or)

JSON:

 {
				id: '',
				minRef: '',
				'name*': 'name',
				reference: '',
				'facilityType*': 'facility type',
				facilityGroup: '',
				'facilityGroup name': '',
				'location.country': 'location.country',
				'location.city': '',
				'location.location': '',
				'location.longitude': '',
				'location.latitude': '',
				estimatedCostLabourPerMonth: '',
				estimatedCostMaterialPerMonth: '',
				constructionDate: '',
				'isActive*': 'TRUE',
			},

Code Example

const csvContent = json2csv(workOrders);

moHaHa avatar May 24 '24 13:05 moHaHa