I am trying to create JSON from a multi-array in the following format:
var qus ={
{
"qus" :"what is your name?",
"option1" : {"ans" : Alex, "cor:"false"},
"option2" : {"ans" : Hervy, "cor:"false"},
"option3" : {"ans" : Rico, "cor:"true"},
"option4" : {"ans" : Tom, "cor:"false"},
},
{
"qus" :"what is your brother's name?",
"option1" : {"ans" : Alex, "cor:"false"},
"option2" : {"ans" : Hervy, "cor:"true"},
"option3" : {"ans" : Rico, "cor:"false"},
"option4" : {"ans" : Tom, "cor:"false"},
},
}
However, when I input the array values through a textarea, it fails to generate the JSON correctly. You can see the issue with the generated code here: http://plnkr.co/edit/hvuLXL1SPntlqtAV8iEW?p=preview. It seems to be adding unnecessary line breaks.
In another example, everything gets distorted and broken up like this: http://plnkr.co/edit/5qzsSSzv6oXV4QRpPa36?p=preview.
Could you help me understand why extracting values from a textarea is causing these issues? How can I fix the messed-up Plunkers to get the desired JSON output?