The specific String in question was originally part of a JavaScript object as shown below:
var nameVal = "Jacob";
var favNumbersVal = "{\"firstNum\":0, \"secondNum\":1, \"thirdNum\":2}";
var aJSObject = {
"name" = nameVal,
"favNumbers" = favNumbersVal
};
I am particularly interested in the variable favNumbersVal
. It is important to note that the quotation marks surrounding the value of favNumbersVal
are standard double quotes used when defining a string.
The structure of the value in favNumbersVal
is generated by a library dynamically.
My query is how can I convert the content of favNumbersVal
into a JavaScript object, so that when I eventually transform sJSObject
into JSON using JSON.stringify()
, the value of aJSObject
will be a JSON object with the value of favNumbers
nested within it.