How to remove redundant quotation marks in dynamically created json object with javascript? How to remove redundant quotation marks in dynamically created json object with javascript? json json

How to remove redundant quotation marks in dynamically created json object with javascript?


Do not push the object as string, rather do it as an object. Change this part where you are sending it:

sound_files.push("{mp3: \"my_directory/" + mp3 + "\"}");

As an object:

sound_files.push({mp3: "my_directory/" + mp3});


Try sound_files.push({mp3: "my_directory/" + mp3});


You are currently creating strings that contain the JavaScript source code needed to construct an object.

Just create objects instead.

sound_files.push({mp3: "my_directory/" + mp3});