-1

Below is my JSON format:

{
    "Heading": "Issue",
    "HeadingCtnt": "testit",
    "Cause": "",
    "SecHeading": "Workaround",
    "SecHeadingCtnt": "",
    "AddInfo": ""
}

My code to parse JSON:

data = JSON.parse(content);

Even though its a valid JSON, I am getting an error as below:

Uncaught SyntaxError: Unexpected token < in JSON at position 0

Any suggestions as to where I am going wrong?

Thanks!

user2598808
  • 633
  • 5
  • 22
  • 40

1 Answers1

1

In your post content is a javascript object. You have to convert it to string as json parser takes only string.

Update your json by adding single quotes as shown below.

var content = 
'{"Heading": "Issue", "HeadingCtnt": "testit","Cause": "","SecHeading":"Workaround","SecHeadingCtnt":"" ,"AddInfo": ""}';
Srini
  • 76
  • 9