Skip to content

Instantly share code, notes, and snippets.

@guilhermehn
Created June 21, 2013 18:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guilhermehn/5833114 to your computer and use it in GitHub Desktop.
Save guilhermehn/5833114 to your computer and use it in GitHub Desktop.
tuenti_secure JSON parser
function tuenti_secure(string) {
var regexp1 = /^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/,
regexp2 = /\\./g,
regexp3 = /"[^"\\\n\r]*"/g;
if (!string || typeof string !== "string") {
return null;
}
if (regexp1.test(string.replace(regexp2, "@").replace(regexp3, ""))) {
return null;
}
return eval("(" + string + ")");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment