// 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);