0

Hi I am getting a string like below when parsing a CSV file using csvtojson npm module .

"{"baselineWifiStrength":"10Mbps","userWifiStrength":"3Mbps"}"

Code to read from csv

const csvData = req.files.csvfile.data.toString('utf8');

 csvtojson().fromString(csvData).then(async (json) =>{

        const queriesNew = json.map(async (l) => {
        JSON.parse(l.structure); // crashes here 
})


})

How can I convert the above to a valid JSON Object . I am getting parse error If I do JSON.parse(). Is there a way to solve this ?

Basically I want to convert the "{"baselineWifiStrength":"10Mbps","userWifiStrength":"3Mbps"}" to valid JSON

naveen
  • 107
  • 1
  • 1
  • 10

0 Answers0