I have the following string and would like to convert it to json in javascript/node.js.
Issues:
- It has \r\n not just \n
- There are , in the fields, for example in the description
- There are " which need to be removed but also could be in the description.
Perhaps there is a better way to process the multer.buffer than toString() ?
"name,description\r\nParis,The home of the eiffel tower\r\nMadrid,Madrid is home to two world-famous football clubs, Real Madrid and Atletico Madrid\r\n"
Prefered Output:
[
{
"name": "Florida beach getaway",
"description": "Soft beach sands, warm sunsets, calm waters"
},
{
"name": "Iceland",
"description": "Explore the dramatic landscape with volcanoes, geysers, hot springs and lava fields"
}
]
I have tried csv-parse and papa-parse and neither are able to handle this line,
Madrid is home to two world-famous football clubs, Real Madrid and Atletico Madrid