ParseJSON Simplified


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function parseJSON(json){
  2. try{
  3. if(/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test(json)){
  4. var j = eval('(' + json + ')');
  5. return j;
  6. }
  7. }catch(e){
  8. }
  9. throw new SyntaxError("parseJSON");
  10. }

URL: http://www.json.org/js.html

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.