Uncaught SyntaxError: Unexpected token p in JSON at position 15

Viewed 23599

I have the Json data , which I am trying to parse in the following fiddle

but its throwing error

Uncaught SyntaxError: Unexpected token p in JSON at position 15

I am unable to paste the json here due to the large size kindly follow the fiddle

var varArray = JSON.parse(jsonData);

console.log(varArray);

Fiddle

https://jsfiddle.net/ffeLtaa6/

any suggestion ?

3 Answers

I had a the same error "Uncaught SyntaxError: Unexpected token P in JSON at position 0" the code was working but this message was shown on console with status 200

in my case i managed to avoid the error message by changing the return type from String to Integer

like this:

//before
public String method(){
  //code here
  return "evrything went as expected";
}



//after
public Integer method(){
  //code here
  return 0;
}

I think this has something to do with the browser that is expecting to get integers, im gonna update this answer if i discover something else

Related