Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

json parse cause Unexpected token in JSON at position 550

// preserve newlines, etc - use valid JSON
s = s.replace(/
/g, "
")  
               .replace(/'/g, "'")
               .replace(/"/g, '"')
               .replace(/&/g, "&")
               .replace(/
/g, "
")
               .replace(/	/g, "	")
               .replace(//g, "")
               .replace(/f/g, "f");
// remove non-printable and other non-valid JSON chars
s = s.replace(/[u0000-u0019]+/g,""); 
var o = JSON.parse(s);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #json #parse #Unexpected #token #JSON #position
ADD COMMENT
Topic
Name
6+2 =