I am trying to create a function that parses JSON text.
function JSONParser(string) {
//CODE HERE
string = string.replace(/"/g, "");
var obj = {};
obj[0] = string;
string = obj[0].replace(/'/g, "");
return string;
}
I only did the funky thing with the object because .replace didn't seem to work directly on the string the second time.
When I run this code through a checker. I get...
JSONParser(JSON.stringify(true));
"true"
I am aiming to return the boolean true and not a string.
Does anyone know why I still get a return with double quotes? Is there more to changing a string object than removing the quotes? Or, am I simply trying to remove them incorrectly?
Any help would be greatly appreciated. TIA
-Lea