In JS I have a string variable as follows: Text JSON Data:
[{ "id" : "3", "parent" : "2", "text" : "Lack of Survey Information" },{ "id" : "4", "parent" : "3", "text" : "Lack of Surveyor Resource" },{ "id" : "5", "parent" : "3", "text" : "Land access unavailable" },{ "id" : "2", "parent" : "1", "text" : "Design Incorrect" },{ "id" : "1", "parent" : "16", "text" : "Abortive Work" },{ "id" : "6", "parent" : "1", "text" : "Wrong design info used in construction" },{ "id" : "16", "parent" : "#", "text" : "a" }]
This is output from the following code:
console.log("Text JSON Data:"+strJSON)
var objJSON=$.parseJSON(strJSON)
var objJSON=JSON.parse(strJSON)
It parses using $.parseJSON but does not parse using JSON.parse (I get a bizarre "Uncaught TypeError: JSON.parse is not a function" error though it clearly is). I am using Chrome. It gets weirder, when I just use $.parseJSON successfully and then use JSON.stringify on the returned JSON object it crashes and also throws up an error.
What is weird is that I pass several other JSON strings to this function and they are parsed fine. I thought it might be something to do with the '#' symbol but it seems to parse OK in JSFiddle. I know when using VBA that sometimes an error code is triggered for a line of code when in fact the error is caused by something else. I am wondering if that is what is going on here.
What I need to understand is why this particular string is triggering the bizarre errors.