Skip to content Skip to sidebar Skip to footer

Uncaught Syntaxerror: Unexpected Token P In Json At Position 36

I´m populating webpage with sharepoint so I do a json to get data with ajax like these: function completeFleet(data, target, eng) { var items = data.d.results; console.log(items);

Solution 1:

make sure value is not null for the corresponding key inside JSON.parse. For example-

JSON.parse(items[item].Specifications)

make sure items have value in item index and items[item] has the property Specifications.

you can check if items[item].Specifications is not null before JSON.parse.

if(items[item].Specifications){
  JSON.parse(items[item].Specifications)
}

Update

JSON.parse() is used to convert a string containing JSON notation into a Javascript object. To be valid JSON, strings must be in double quotes.

Try stringify the object and then parse again.

var stringifyObj = JSON.stringify(items[item].Especificaciones); 
var obj = JSON.parse(stringifyObj);

The reason for the error is that JSON.parse() expects a String value and items[item].Especificaciones is an Array

Solution 2:

"Eslora":100 pies"

You should probably opening the quotes when you start writing a string value

Post a Comment for "Uncaught Syntaxerror: Unexpected Token P In Json At Position 36"