Posted By

ecavazos on 01/24/08


Tagged

parse json


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

adix
rafael


ParseJSON Simplified


 / Published in: JavaScript
 

URL: http://www.json.org/js.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. }

Report this snippet  

You need to login to post a comment.